Good afternoon everyone
I want to set up a general script where I can pass the server name from a .bat script when calling .ps1
In my bat script I have this statement:
set setver_name=our2008server
powershell -ExecutionPolicy RemoteSigned
-NonInteractive
-NoProfile
-command
"& '\\serverd1\d$\Program Files\%run_dir%\Dcls\PS\Stop_Bkgnd_%run_env%_01.ps1' "
-server_name %server_name%
in my ps1 script I have:
gwmi win32_service -Computername $server_name -filter "name = 'BackgroundQueue'" |
% {$_.StopService()}
If I replace $ server_name with the actual server name, it works fine. I just canβt get the variable from the .bat file for recognition in .ps1.
Any help would be greatly appreciated.
Bobz
source
share