Can one set a variable via the command line ?

0

I would like to set a PDQ Deploy variable via the command line and then access that variable by a deployment. Can a variable be set via the command line?

Thanks, Nick

Cancel
login to comment
0

That's a pretty general question I think it depends on the context of what you're trying to accomplish. But I have pretty general answer: You could write to a file and check it later. For example,

echo yes > %WINDIR%\AdminArsenal\pending_reboot.txt

Then add a reboot step with a condition that depends if that file exists. Or if you need to read in the contents of the text file to retrieve a variable value you could use powershell,

$reboot_yes_no = "no" # this would be the default value
$reboot_variable = $env:windir\AdminArsenal\pending_reboot.txt
if(Test-Path $reboot_variable){
  $reboot_yes_no = Get-Content $reboot_variable;
  $reboot_yes_no = $reboot_yes_no.Trim() # this would be the new value read-in from the file
  Remove-Item -Path $reboot_variable -Force # delete the file after for clean up.
}

if($reboot_yes_no -eq "yes"){
  Restart-Computer
}

You get the idea.

Cancel
login to comment

Reply