Link to home
Start Free TrialLog in
Avatar of iddisarl
iddisarl

asked on

POWERSHELL Invoke-Command problem with many arguments

Hello,
i have a problem with this powershell code:


$jobname=$args[0]
$srvBEname=$args[1]

Invoke-Command -ComputerName  $srvBEname-ScriptBlock { 

if (!$jobname) { Write-Host "variable is null"; exit(1)}


}-Args $jobname

Open in new window


how i can pass arg $jobname on the remote command
with this code i always have null for my last argument.
thank you for help
Avatar of YZlat
YZlat
Flag of United States of America image

try

$jobname=$args[0]
$srvBEname=$args[1]

Invoke-Command -ComputerName  $srvBEname-ScriptBlock { 

if ($jobname -eq $null) { Write-Host "variable is null"; exit(1)}


}-Args $jobname 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iddisarl
iddisarl

ASKER

thank you,
it's works with the first code.
regards.