######################################################### # # Name: ConfigureContacts.ps1 # Author: Tony Murray # Version: 2.0 # Date: 31/12/2010 # Comment: Creates a remote powershell session to an # Exchange Server in another forest and touches Contact # objects so that they become visible in the GAL. # # Designed to be used with Quest Quick Connect Express # ######################################################### # Logon to use to connect to remote Exchange Server $exAdmin = "SOUTH\Administrator" # URI for the remote Exchange Server $connectionUri = "http://s1.south.com/PowerShell/" # The following command can be used outside this script # to store the password in a local file # read-host -assecurestring | convertfrom-securestring | out-file "c:\util\password.txt" # Location of file containing password for logon for $exAdmin $passwordFile = "c:\util\password.txt" # Get the encrypted password from file $password = Get-Content $passwordFile | ConvertTo-SecureString # Specify the PS credentials $credential = New-Object System.Management.Automation.PSCredential $exAdmin,$password # OU where the Contact objects are located $ContactOU = "OU=NORTH Contacts,DC=south,DC=com" # Create a new Powershell remote session $Session = New-PSSession –ConfigurationName Microsoft.Exchange ` –ConnectionUri $connectionUri –Credential $Credential Import-PSSession $Session # -AllowClobber # Touch the contacts to make them visible in the GAL Get-MailContact -OrganizationalUnit $ContactOU | ? {$_.legacyExchangeDN -eq ""} | Set-MailContact # Tidy up by closing the session we created. Remove-PSSession $Session # End