08-09-2023 10:51 PM
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!
Solved! Go to Solution.
08-11-2023 04:01 PM
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%}
08-11-2023 04:30 PM - edited 08-11-2023 04:34 PM
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
<?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>
08-11-2023 04:04 PM
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.
08-11-2023 04:16 PM
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 🙂
08-11-2023 04:24 PM
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?
08-11-2023 04:30 PM - edited 08-11-2023 04:34 PM
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
<?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>
08-11-2023 07:40 PM
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.
08-11-2023 04:45 PM
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.
08-11-2023 04:21 PM
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.
08-11-2023 04:01 PM
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%}
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now