cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JRall
Engaged Sweeper III

I am trying to use a deployment command to trigger a PDQ deployment package. It works if I manually type out the target computer name, but I really would need it to pass the computers name. I have tried the {smartname} and $env:computername variables. Does anyone know if this is possible? I will post the command below for reference.

 

powershell.exe -executionpolicy bypass Invoke-Command -ComputerName "HOST-PC" -ScriptBlock {pdqdeploy Deploy -Package "PackageName" -Targets "TargetPC"}

 

Thanks!

2 ACCEPTED SOLUTIONS
ASismey
Engaged Sweeper III

Not tested this script, but could you not launch a batch file like this on the pc , grab the computer name of the local computer as a variable ? 

set host=%COMPUTERNAME%
powershell.exe -executionpolicy bypass Invoke-Command -ComputerName %host% -ScriptBlock {pdqdeploy Deploy -Package "PackageName" -Targets %host%}

 

View solution in original post

ASismey
Engaged Sweeper III

Yes thats correct so you just create a 1 step deployment , import the example below call your script launch.bat, that should work for you, may need to play with the batch file a bit and the variable 

ASismey_0-1691764414663.png

 

 

<?xml version="1.0" encoding="utf-8"?>
<Package>
  <Name>Deploy PDQ</Name>
  <Description></Description>
  <ShutdownOption>0</ShutdownOption>
  <ShutdownTime>0</ShutdownTime>
  <MaxDuration>900</MaxDuration>
  <Rescan>True</Rescan>
  <RunMode>2</RunMode>
  <Steps>
    <Step>
      <Nr>1</Nr>
      <Name>PDQ Install1</Name>
      <Type>4</Type>
      <ReturnCodes>0,1641,3010</ReturnCodes>
      <Success>-2</Success>
      <Failure>-3</Failure>
      <Path>{PackageShare}\Scripts\launch.bat</Path>
      <Parameters></Parameters>
      <MSIParameters></MSIParameters>
      <MSIName></MSIName>
      <MSIVersion></MSIVersion>
      <Command>"{PackageShare}\Scripts\launch.bat"</Command>
      <EditMode>False</EditMode>
      <Conditions />
    </Step>
  </Steps>
  <SoftwareVersion>10.4.1.3</SoftwareVersion>
</Package>

 

 

 

View solution in original post

8 REPLIES 8
JRall
Engaged Sweeper III

Possibly, but wouldn't this require a batch file to each PC I am sending this command to? I was trying to avoid that as there is always different packages I am deploying to different PC's and that could end up being a pain. Was hoping to pass the PC name with a command, but it may not be possible.

ASismey
Engaged Sweeper III

So are you doing this through the "Deployment Package"  or "Asset Action" , if its via Deployment Package, it would mean the script is run on each pc , but the %ComputerName% would be the same as having {smartname} in the powershell script? , silly question but why don't you just create the deployments in Lansweeper 🙂

JRall
Engaged Sweeper III

I think I may understand what your first suggestion was. Basically I would add the batch file to the Package Share location in the scripts folder and then create a Script step pointing to that script file in the Package Share correct?

ASismey
Engaged Sweeper III

Yes thats correct so you just create a 1 step deployment , import the example below call your script launch.bat, that should work for you, may need to play with the batch file a bit and the variable 

ASismey_0-1691764414663.png

 

 

<?xml version="1.0" encoding="utf-8"?>
<Package>
  <Name>Deploy PDQ</Name>
  <Description></Description>
  <ShutdownOption>0</ShutdownOption>
  <ShutdownTime>0</ShutdownTime>
  <MaxDuration>900</MaxDuration>
  <Rescan>True</Rescan>
  <RunMode>2</RunMode>
  <Steps>
    <Step>
      <Nr>1</Nr>
      <Name>PDQ Install1</Name>
      <Type>4</Type>
      <ReturnCodes>0,1641,3010</ReturnCodes>
      <Success>-2</Success>
      <Failure>-3</Failure>
      <Path>{PackageShare}\Scripts\launch.bat</Path>
      <Parameters></Parameters>
      <MSIParameters></MSIParameters>
      <MSIName></MSIName>
      <MSIVersion></MSIVersion>
      <Command>"{PackageShare}\Scripts\launch.bat"</Command>
      <EditMode>False</EditMode>
      <Conditions />
    </Step>
  </Steps>
  <SoftwareVersion>10.4.1.3</SoftwareVersion>
</Package>

 

 

 

JRall
Engaged Sweeper III

Hey again ASismey, using a batch script with the variable worked perfect. I didn't have to change anything with the script you sent other than package name and the first host field. Thanks again, this may make things easier for me being able to initiate deployments based on reports. Especially if I automate this as some point for certain things.

JRall
Engaged Sweeper III

Awesome, thanks ASismey. I will have to try that out as soon as I get a chance. Hopefully that will end up working out as needed. Looks like it may, but if not, I may be able to tweak it a bit if needed to work.

JRall
Engaged Sweeper III

I am doing this through the "Deployment Package". Maybe I am misunderstanding how to add the script in Lansweeper. I will have to take a look. I already have a bunch of packages setup in PDQ and find it much easier/quicker to setup multiple step or nested packages and seems to have more capabilities as well. I was just trying to find a way to trigger these PDQ deployments using reports in Lansweeper. Kind of bridging the two together in a sense.

Maybe sometime I need to see if I can convert some of my deployments to Lansweeper instead.

ASismey
Engaged Sweeper III

Not tested this script, but could you not launch a batch file like this on the pc , grab the computer name of the local computer as a variable ? 

set host=%COMPUTERNAME%
powershell.exe -executionpolicy bypass Invoke-Command -ComputerName %host% -ScriptBlock {pdqdeploy Deploy -Package "PackageName" -Targets %host%}