Sunday 15 April 2012

Mapping drive on a remote machine in powershell -


I am working on a remote machine from my desktop and I have the following script: < Blockquote>

come-command - password name $ name-authentication default -activation $ creds1 -scriptblock {net use \ $ share password / user: other domain \ other user}

Then I get a specified logon session does not exist. It may have been terminated already, this thing is disappointing because if I run the pure use \\ share $ password2 / user: otherdomain \ otheruser it works perfectly on a remote machine Is there any remedy or am I missing something?

You have to pass the variable $ password2 in the script block, otherwise its value Empty:

  come-command-computer $ name ... -scriptblock {use net \\ host \ share $ args [0] / user: otherdomain \ other user} -registration $ Password 2    

No comments:

Post a Comment