Powershell-Skripte¶
Setzen als Mail-Kontakte¶
Hinweis
Die verwendeten Poweshell-Skripte enthalten einige Platzhalter, welche durch das ADCEITool vor der Ausführung ersetzt werden.
#Define Logfile-Paths and settings $ExecutionPath="##EXECUTION_PATH##" $LogFileSuccess="$($ExecutionPath)\SuccessLog.txt" $LogFileError="$($ExecutionPath)\ErrorLog.txt" $LoggingEnabled=$##LOGGING_ENABLED## #Append message to success-log Function LogSuccess { Param ([string]$logstring) if($LoggingEnabled -eq $TRUE){ Add-content $LogFileSuccess -value "$(Get-Date -Format dd.MM.yyyy) $((Get-Date).ToLongTimeString()): $($logstring)" } } #Append message to error-log Function LogError { Param ([string]$logstring) if($LoggingEnabled -eq $TRUE){ Add-content $LogFileError -value "$(Get-Date -Format dd.MM.yyyy) $((Get-Date).ToLongTimeString()): $($logstring)" } } #Load temporary password file and put together remote-pssessions credentials $cred = New-Object System.Management.Automation.PSCredential ("##username##", (Get-Content "$($ExecutionPath)\pwfile.pw" | ConvertTo-SecureString)) #Log success-message if logging is enabled LogSuccess "Establishing remote pssession." #Create remote ps-session to exchange server $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://##exchange_server##/PowerShell/ -Authentication Kerberos -Credential $cred #Import the created ps-session Import-PSSession $Session #Log success-message if logging is enabled LogSuccess "Exchange remote pssession established. Start mail enabling contacts." #Import temporary csv-file, for every row use command "Enable-MailContact" Import-CSV "$($ExecutionPath)\tmp.csv" | Foreach-Object{Enable-MailContact -Identity $_.guid -ExternalEmailAddress $_.externalMailAddress} #Log success-message if logging is enabled LogSuccess "Mail enabling finished."