Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Invoke Command not reading a parameter

$
0
0

Hi there

I'm just testing a section of my script whereby i want to eliminate hard coding a version folder and pass something like this

Login credentials are passed in the script from another XML so that logging into the server is not an issue.

$deployversion = "v4"

Write-Host "copied Register.bat to \\$server\e$\$deployversion\Assets\bin\"  

$reg = invoke-command -computername ServerA -ScriptBlock {Set-Location "E:\$deployversion\Assets\bin"; & ".\Register.bat"} -erroraction 'stop' -credential $cred

When i run this script on it's own in PowerGUI script editor, i get message saying unable to find E:\$deployversion\Assets\bin folder on the server. So looks like $deployversion is not getting passed to the invoke command.

please can you advise how to resolve this issue?


Viewing all articles
Browse latest Browse all 6937

Trending Articles