Declare Array List
Method 1:
[System.Collections.ArrayList]$ArrayList = @()
Method 2:
$ArrayList = [System.Collections.ArrayList]@()
Method 3:
$ArrayList = [System.Collections.ArrayList]::new()
Method 4:
$ArrayList = New-Object System.Collections.ArrayList($Null)
Method 5:
$ArrayList = New-Object System.Collections.ArrayList(,(1..10))
Method 6:
$ArrayList = New-Object System.Collections.ArrayList
Mailbox Permission
$upn = (Get-Mailbox -RecipientTypeDetails usermailbox)
$out = $null
$out=[System.Collections.ArrayList]@()
Foreach($u in $UPN)
{
$data = Get-MailboxPermission $u.userprincipalname |select User,AccessRights
@($data).ForEach({
$property= [ordered]@{
'DisplayName' = $u.DisplayName
'AccessRights' = $_.AccessRights
'User' = $_.User
}
$obj = New-Object psobject -Property $property
#Adding values to Array List
$out.Add($obj)
})
}
$out
Method 1:
[System.Collections.ArrayList]$ArrayList = @()
Method 2:
$ArrayList = [System.Collections.ArrayList]@()
Method 3:
$ArrayList = [System.Collections.ArrayList]::new()
Method 4:
$ArrayList = New-Object System.Collections.ArrayList($Null)
Method 5:
$ArrayList = New-Object System.Collections.ArrayList(,(1..10))
Method 6:
$ArrayList = New-Object System.Collections.ArrayList
Mailbox Permission
$upn = (Get-Mailbox -RecipientTypeDetails usermailbox)
$out = $null
$out=[System.Collections.ArrayList]@()
Foreach($u in $UPN)
{
$data = Get-MailboxPermission $u.userprincipalname |select User,AccessRights
@($data).ForEach({
$property= [ordered]@{
'DisplayName' = $u.DisplayName
'AccessRights' = $_.AccessRights
'User' = $_.User
}
$obj = New-Object psobject -Property $property
#Adding values to Array List
$out.Add($obj)
})
}
$out
No comments:
Post a Comment