Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
<# Creator @ryandengstrom -
Used to maintain a softpaq repository for each model specified in the HPModelsTable.
This Script was created to script maintenance of softpaq repositories, which are used with HP SSM during OSD/IPU task sequences.
HP Client Management Script Library
Download / Installer:
SSM Update Script
This script was created using version 1.2 (
HP: Nathan Kofahl (@nkofahl) was very helpful in answering questions about the cmdlets and a place to report bugs.
Loop Code: The HPModelsTable loop code (and other general code) was taken from Gary Blok's (@gwblok) post on
Logging: The Log function was created by Ryan Ephgrave (@ephingposh)
$OS = "Win10"
$OSVER = "1803"
$SSMONLY = "ssm"
$Category1 = "bios"
$Category2 = "driver"
$RepositoryPath = "E:\HPRepository"
$LogFile = "$RepositoryPath\RepoUpdate.log"
$HPModelsTable= @(
@{ ProdCode = '1998'; Model = "HP EliteDesk 800 G1 SFF" }
@{ ProdCode = '829A'; Model = "HP EliteDesk 800 G3 DM 35W" }
@{ ProdCode = '8299'; Model = "HP EliteDesk 800 G3 SFF" }
@{ ProdCode = '837B'; Model = "HP ProBook 440 G5" }
@{ ProdCode = '2101'; Model = "HP ProBook 640 G1" }
@{ ProdCode = '80FD'; Model = "HP ProBook 640 G2" }
@{ ProdCode = '818F'; Model = "HP ProBook 11 G2" }
foreach ($Model in $HPModelsTable) {
Log -Message "----------------------------------------------------------------------------" -LogFile $LogFile
Log -Message "Checking if repository for model $($Model.Model) aka $($Model.ProdCode) exists" -LogFile $LogFile
if (Test-Path "$($RepositoryPath)\$($Model.Model)") { Log -Message "Repository for model $($Model.Model) aka $($Model.ProdCode) already exists"-LogFile $LogFile }
if (-not (Test-Path "$($RepositoryPath)\$($Model.Model)")) {
Log -Message "Repository for $($Model.Model) does not exist, creating now" -LogFile $LogFile
New-Item -ItemType Directory -Path "$($RepositoryPath)\$($Model.Model)\Repository"
if (Test-Path "$($RepositoryPath)\$($Model.Model)\Repository") {
Log -Message "$($Model.Model) repository folder and SSM Repository subfolder successfully created" -LogFile $LogFile
else {
Log -Message "Failed to create SSM repository subfolder!" -LogFile $LogFile
elseif (-not (Test-Path "$($RepositoryPath)\$($Model.Model)\Repository")) {
Log -Message "SSM Repository subfolder for $($Model.Model) does not exist, creating now" -LogFile $LogFile
New-Item -ItemType Directory -Path "$($RepositoryPath)\$($Model.Model)\Repository"
if (Test-Path "$($RepositoryPath)\$($Model.Model)\Repository") {
Log -Message "$($Model.Model) SSM repository subfolder successfully created" -LogFile $LogFile
else {
Log -Message "Failed to create repository folder for $($Model.Model)" -LogFile $LogFile
if (-not (Test-Path "$($RepositoryPath)\$($Model.Model)\Repository\.repository")) {
Log -Message "Repository not initialized, initializing now" -LogFile $LogFile
Set-Location -Path "$($RepositoryPath)\$($Model.Model)\Repository"
if (Test-Path "$($RepositoryPath)\$($Model.Model)\Repository\.repository") {
Log -Message "$($Model.Model) repository successfully initialized" -LogFile $LogFile
else {
Log -Message "Failed to initialize repository for $($Model.Model)" -LogFile $LogFile
Log -Message "Set location to $($Model.Model) repository" -LogFile $LogFile
Set-Location -Path "$($RepositoryPath)\$($Model.Model)\Repository"
Log -Message "Configure notification for $($Model.Model)" -LogFile $LogFile
Add-RepositorySyncFailureRecipient -to
Log -Message "Remove any existing repository filter for $($Model.Model) repository" -LogFile $LogFile
Remove-RepositoryFilter -platform $($Model.ProdCode) -yes
Log -Message "Applying repository filter to $($Model.Model) repository ($os $osver, $Category1 and $Category2)" -LogFile $LogFile
Add-RepositoryFilter -platform $($Model.ProdCode) -os $OS -osver $OSVER -characteristic $SSMONLY -category $Category1
Add-RepositoryFilter -platform $($Model.ProdCode) -os $OS -osver $OSVER -characteristic $SSMONLY -category $Category2
Log -Message "Invoking repository sync for $($Model.Model) repository ($os $osver, $Category1 and $Category2)" -LogFile $LogFile
Log -Message "Invoking repository cleanup for $($Model.Model) repository for $Category1 and $Category2 category"-LogFile $LogFile
Log -Message "Confirm SSM files are up to date for $($Model.Model)"-LogFile $LogFile
$RobocopySource = "$($RepositoryPath)\SSM Base"
$RobocopyDest = "$($RepositoryPath)\$($Model.Model)"
$RobocopyArg = '"'+$RobocopySource+'"'+' "'+$RobocopyDest+'"'
$RobocopyCmd = "robocopy.exe"
Start-Process -FilePath $RobocopyCmd -ArgumentList $RobocopyArg -Wait
Log -Message "Rebuilding the SSM UID in Administrative Mode"-LogFile $LogFile
Start-Process -FilePath "$($RepositoryPath)\$($Model.Model)\ssm.exe" -ArgumentList "/am_bld_db" -Wait
Log -Message "----------------------------------------------------------------------------" -LogFile $LogFile
Log -Message "Repository Update Complete"-LogFile $LogFile
Log -Message "----------------------------------------------------------------------------" -LogFile $LogFile
Set-Location -Path $RepositoryPath