Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Odd behavior with ADSI query in Remote Powershell

$
0
0

You would see that when I use a variable to capture the value and echo then it returns nothing. But if I directly echo it, it prints the results. This only happens when I execute the command remotely, the local version for the same command works fine.

PS C:\Users\Administrator.ITAPP> invoke-command -computername a01-a01-admin-2 -scriptblock { $dn = ([ADSI]"").distinguis
hedName; echo $dn } -credential $cred
PS C:\Users\Administrator.ITAPP> invoke-command -computername a01-a01-admin-2 -scriptblock { echo ([ADSI]"").distinguish
edName} -credential $cred
DC=itapp,DC=com

PS C:\Users\Administrator.ITAPP> invoke-command -scriptblock { $dn = ([ADSI]"").distinguishedName; echo $dn }
DC=itapp,DC=com

I would very much appreciate any help in resolving this. Thanks much. Merry Christmas!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>