I have a file called file.ps1 with the following code:
$varsent=$args[0]
echo $varsent
when I tried to call this ps1 file with the following command because I need execute ps1 with elevated rights:
$var = "test"
Start-Process powershell -ArgumentList '-noprofile -file "\\network path with spaces\file.ps1" $var ' -verb RunAs
Result is the word "$var" instead "test"
But with
Start-Process powershell -ArgumentList '-noprofile -file "\\network path with spaces\file.ps1" test ' -verb RunAs
result is word "test"
I think that problem is that $var is not replaced by its value when code is executed but I do not why. Please, can you help me? I must use $var.