# Use this script to refresh a list content to a specific dp, or a list of dps to a specific piece of content.
# Paste output list from SQL of packageids
$PKGIDS = @"
"@
# Paste output list from SQL of the full servernalpaths
$serverNalPath = @"
"@
<# Begin #>
<# do not modify below #>
# Splitting up the Here strings for Packageids and Servernalpaths to turn it into an array of objects
$PKGIDS = $PKGIDS.Split("`r`n") | Where-Object {$_ -ne ""}
$ServerNalPath = $ServerNalPath.Split("`r`n") | Where-Object {$_ -ne ""}
$ServerShortName = $ServerNalPath | % {$_.Split("\\")[5]}
# Testing the counts of the arrays to make sure we don't loop improperly
$ErrorActionPreference = "Stop"
$shouldrun = $false
if ($PKGIDS.count -eq 1 -and $ServerShortName.count -ge 1) {$shouldrun = $true}
elseif ($PKGIDS.count -ge 1 -and $ServerShortName.count -eq 1) {$shouldrun = $true}
else {$shouldrun = $false}
if ($shouldrun) {
$ServerShortName | % {
$ServerNalPath = $_
$PKGIDS | % {
TRY {
$PKGID = $_
$DP = gwmi -ComputerName xxxxxx -Class sms_distributionpoint -filter "ServerNALPath like '%$ServerNalPath%' and packageid = `'$PKGID`'" -Namespace root\sms\site_XXX
$dp.RefreshNow = $true
$dp.put() | Out-Null
Write-Output "Success - Refreshing $PKGID on $ServerNalPath"
}
CATCH {
Write-Output "Error - Refreshing $PKGID on $ServerNalPath"
}
}
}
}
else {
Write-Output "Error - Script only supports running against a single packageid or a single servernal path at a time, validate input"
}
<# END #>