Closed buzzzo closed 5 days ago
You can't define a PowerShell list in a batch file. The easiest way to do this is to edit the EWSContactSync.ps1 file. Change the Mandatory value of the MailboxList parameter from $True to $False. Then, write in your custom addresses in the following format: @(email1, email2, emai3, etc...). At this point, you should remove the MailboxList argument from your batch file since you already defined the emails in EWSContactSync.ps1. See below for an example of what EWSContactSync.ps1 should look like. Hopefully this helps.
[Parameter(Mandatory=$False)]
[String[]]
$MailboxList = @(john.doe1@mycompany.com, john.doe2@mycompany.com, , john.doe3@mycompany.com)
Thx for response.
I've ended up by modifying the ps1 file but just let get the email addresses list from an external file and then populate the array via foreach loop.
Thx for help
Hi Buzzzo,
Do you have an example of the modified ps1 file?
@buzzzo do you have an example of the file/foreach loop that you can share?
Hi
I've manage to create a txt file with all the mailbox name to sync and calling it in the EWSContactSync script to populate an array.
So: 1) an external script create a file with ALL the username@domain i would like to sync. This is the script: (Group_To_Sync is the nome of the AD group holding ALL the user i would like to create the gal, so basically of user in this group will be written in mailboxsync.txt file)
$file = "c:\o365\gal-exo\mailboxtosync.txt"
if (Test-Path $file ) { Remove-Item $file }
$users = Get-ADGroupMember Group_ToSync | %{get-aduser $.SamAccountName | select userPrincipalName } | Select-Object -ExpandProperty userPrincipalName |Out-File -filepath $file
2) I've add this on ewcontactsync script:
if ( Test-Path -Path "c:\o365\gal-exo\mailboxtosync.txt" -PathType Leaf ) { $MailboxList = Get-Content -Path @("C:\o365\gal-exo\mailboxtosync.txt") }
Of course you need to run script1 BEFORE ewcontactsync script in order to create the mailboxtosync.txt script
Hope this can help
As per subject I can't figure out the exact syntax of -mailboxlist when using more than one entries. Every time i'm trying to specify in some format the script gives error.
Thx