It seem like everyone who answers this question skirts the issue by giving example that either A. Aren't relevant; or, B. Use the -scriptBlock
version.
Here is what I want: I want to run a PowerShell script from my local machine, on a remote machine. I need to pass in an argument or parameter.
Here is what I'm doing:
$responseObject = Invoke-Command -ComputerName MININT-OU9K10R -FilePath C:\Users\Documents\RemoteProofOfConcept\validatePath.ps1 -ArgumentList $filename -AsJob
I want to pass $filename
into the validatePath.ps1
script, and I can't figure out how to do this.
Can someone please show me how to do this, or tell me what I'm doing wrong?
None of these links have helped:
Get script directory in PowerShell when script is invoked with Invoke-Command
Powershell Invoke-Command with-FilePath Gives ItemNotFoundException