I’m working on a remote powershell script. I can get the powershell to work with a basic Get-Host, but when I try add the Exchange Snapin I get errors.
Invoke-Command -ConnectionUri http://RemoteServer:5985/wsman -ScriptBlock { Get-Host} -credential domain\login
The above works correctly
When I attempt this code:
Invoke-Command -ConnectionUri http://RemoteServer:5985/wsman -ScriptBlock {C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1” -noexit -command “. ‘C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1’” Get-Host} -credential domain\login
This is the errors I’m getting from the above script.
Exception setting “ViewEntireForest”: "An Active Directory error 0x80072030 occ
+ CategoryInfo : NotSpecified: (Exception setti… 0x80072030 occ:String) , RemoteExcep
tion
+ FullyQualifiedErrorId : NativeCommandError
urred while searching for domain controllers in domain server.com: There is no such object on the server.
"
At C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1:19 char:32
-
$global:AdminSessionADSettings. <<<< ViewEntireForest = $false
-
CategoryInfo : InvalidOperation: ( , RuntimeException
-
FullyQualifiedErrorId : PropertyAssignmentException
-
Any ideas on what I can do to get this script working?