Closed S-Mellado closed 1 year ago
@S-Mellado
The below line is causing your issue.
$Mailbox1 = $Comillas + $Mailbox + $Comillas + ','
You don't need to add quotes and commas to each item when you append to an array. PowerShell can handle this by itself.
Furthermore, you don't need to loop through each user to extract the UserPrincipalName. Please try the below code instead to create your UserPrincipalName list.
$array = $(Get-Mailbox -ResultSize unlimited | Where-Object {$_.RecipientTypeDetails -eq "UserMailbox"}).userprincipalname
Closing to due lack of response...
I make a list with an array and foreach, like this:
$UserMailboxes = Get-Mailbox -ResultSize Unlimited | Where {$_.RecipientTypeDetails -eq “UserMailbox”} $array = @() Foreach ($UserMailboxes in $UserMailboxes) { $Mailbox = $UserMailboxes.userprincipalname $Comillas = '"' $Mailbox1 = $Comillas + $Mailbox + $Comillas + ',' $array = $array + $Mailbox1 }
And when I execute the ps1 with the atribute -MailboxList $array I have an error in every mailbox
Can you help me? I don't know what's the problem. Thanks!