Nomad – Delete Package LsZ Files from List of DPs – PowerShell

Ok, this is more for me to reference than others.

Another great post to reference similar issues: https://miketerrill.net/2019/01/07/nomad-software-update-lsz-file-purge-aka-whack-a-mole/

Came across a problem with Nomad not downloading Packages properly, it was downloading the wrong version. (which would fail)
Clients were getting LsZ File (PS100044_1.LsZ) when the Server’s content was actually version 3.
DP’s were not updating the LsZ files, so I deleted them, then it would re-generate with the proper version.

Script does this:
You Provide a list of DP Servers
You Provide a list of Packages you want to remove the LsZ Files for
It loops through servers and deletes any LsZ files it finds for them

$ServerList =
@(
"SCCMDP1.corp.viamonstra.com"
"SCCMDP2.corp.viamonstra.com"
"SCCMDP3.corp.viamonstra.com"
"SCCMDP4.corp.viamonstra.com"
"SCCMDP5.corp.viamonstra.com"

)

$PackageList =
@(
"PS1051A3"
"PS104BC5"
"PS104BC4"
"PS1051A2"
"PS1040FF"
"PS1051A1"
"PS104107"
"PS105195"
"PS105199"
"PS105198"
"PS105197"
"PS105196"
"PS104C4C"
"PS105193"

)

#Custom Install Location For Nomad
$1eLSZFILESFolder = "ProgramFiles\1E\Cache\LSZFILES"

foreach ($Server in $ServerList)
    {
    Write-Host "Starting Query on $Server"
    foreach ($Package in $PackageList)
        {
        #Check if LsZ File (Any Version) for Package exists
        if (Test-Path "\\$Server\d$\$($1eLSZFILESFolder)\$($Package)_*.LsZ")
            {
            #Get Name of File(s)
            $LSZFIle = (Get-ItemProperty -Path "\\$Server\d$\$($1eLSZFILESFolder)\$($Package)_*.LsZ").BaseName
            #ForEach LsZ File Version, report it exist (write-host) then DELETE IT!
            foreach ($LsZ in $LSZFIle)
                {
                $LSZFIleName = "$($LsZ).LsZ"
                $LSZFIleFullPath = "\\$Server\d$\$($1eLSZFILESFolder)\$($LSZFIleName)"
                Write-Host "$LSZFIleName exist"
                Remove-Item $LSZFIleFullPath -Force -Verbose
                }
            }
        }
    }

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.