Question

I'm trying to execute a powershell script located at a remote machine using the below command and it works great

invoke-command (powershell c:\install\install.ps1) -computername box1 -credential (get-credential)

The above script in-turn copies files from a network share (using robocopy) - It fails complaining the location doesn't exist. Found out it was due to permission issue. It works when I explicitly mentioned in the script to use the following credentials for the share

net use \share1\files password /user:username

Is there a way to pass in the same credentials used to run the script to be used by the script to access other resources in the remote machine?

Thanks! Sanjeev

Was it helpful?

Solution

What you need is credSSP. Check this post: http://www.ravichaganti.com/blog/?p=1230

OTHER TIPS

Pass the credentials as arguments to the power shell script when invoking it remotely using invoke-command. Pass these credentials to the next script from install.ps1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top