Hello peeps,
Having a problem running remote PowerShell commands, hoping someone can shed a little light into what I'm doing wrong?
$cred = Get-Credential $sessionoption = New-PSSessionOption -SkipCNCheck $exchangesession = New-PSSession -Credential $cred -ConnectionUri https://example.com/PowerShell -ConfigurationName Microsoft.Exchange -AllowRedirection -SessionOption $sessionoption enter-PSSession $exchangesession Get-Mailbox user1 | select exchangeVersion Get-Mailbox user2 | select prohibitsendquota New-Mailbox -Name "User3" -userprincipalname user3@example.com Set-MailboxautoReplyConfiguration user1 -starttime 05/05/2015 -Endtime 06/05/2015 -AutoReplyState Scheduled -InternalMessage ="test" -ExternalMessage "test" get-exchangeserver
If I manually input this from any PowerShell window it works fine. Running it from ISE as the basis of a much larger script it fails on the set-mailboxautoreplyconfiguration with the below but then runs the last get-exchangeserver command.
Set-MailboxautoReplyConfiguration : Cannot find information about the local server localcomputer.example.com in Active Directory.This may be related to a change in the server name.
At line:8 char:1
+ Set-MailboxautoReplyConfiguration user1 -starttime 05/05/2015 -Endtime 06/05/ ...
Any ideas? It's probably something really obvious but dammed if I know.
Thanks