Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
2019-09-19 Webcast Bonus Content
# Written by Jordan Hammond
###Define Variables
$autopath = "C:\Users\Public\Documents\Admin Arsenal\PDQ Deploy\Repository"
$autopackages = @()
$DBPath = "C:\programdata\Admin Arsenal\PDQ Deploy\Database.db"
###Build Package Objects
$test = New-Object psobject -Property @{
Path = "\test"
ScheduleID = "12"
CustomVariable = "MyVer"
$obs = New-Object psobject -Property @{
Path = "\OBS Studio"
ScheduleID = "15"
CustomVariable = "OBSVer"
###Populate Array
$autopackages += $test, $obs
###To core of That Thing We Are Doing
Foreach($Package in $autopackages){
###Check to see if there is a new Package to Update
If((Get-ChildItem -Directory -Path ($autopath + $Package.path)).count -eq "3"){
###Move The old crap to the Audit Folder and Update the Variable in Inventory and Deploy
$archive = Get-ChildItem -Directory -Path ($autopath + $Package.path) | Where{$ -eq "archive"} | select fullname
Get-ChildItem -Directory -Path ($autopath + $Package.path) | Where{$ -ne "archive"} | sort creationtime | select -First 1 | Move-Item -Destination $archive.FullName
$NewerVersion = Get-ChildItem -Directory -Path ($autopath + $Package.path) | Where{$ -ne "archive"}
& pdqdeploy updatecustomvariable -name $Package.CustomVariable -value $NewerVersion.Name
& pdqinventory updatecustomvariable -name $Package.CustomVariable -value $NewerVersion.Name
###Delete Schedule History
$SQLQuery = "Select Name FROM ScheduleComputers WHERE ScheduleId LIKE $($Package.ScheduleID)"
$ScheduleHistory = $SQLQuery | sqlite3.exe $DBPath
foreach($machine in $ScheduleHistory){
& pdqdeploy DeleteScheduleHistory -Computer $machine -Schedule $Package.ScheduleID

This comment has been minimized.

Copy link

jclambert commented Sep 19, 2019

Interesting... I'll have to play with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.