Refresh Specific Package on Specific DP Using Powershell

Got the following function from Mike Laughlin posted on https://social.technet.microsoft.com/Forums/en-US/cb61182a-d29c-4a59-8601-fe82c0118de1/redistribute-content-to-distribution-point-w-powershell-cmdlet?forum=configmanagersdk.

Save this function in your PowerShell profile or save it as a .ps1 file and run it to load the function into memory.

Function Refresh-SpecificDP {

param(

[Parameter(Position=1,Mandatory=$true)]$siteCode,

[Parameter(Position=2,Mandatory=$true)]$packageID,

[Parameter(Position=3,Mandatory=$true)]$dpName

)

$dpFound = $false

If ($packageID.Length -ne 8)

{

Throw “Invalid package”

}

$distPoints = Get-WmiObject -Namespace “root\SMS\Site_$($siteCode)” -Query “Select * From SMS_DistributionPoint WHERE PackageID=’$packageID'”

ForEach ($dp In $distPoints)

{

If ((($dp.ServerNALPath).ToUpper()).Contains($dpName.ToUpper()))

{

$dpFound = $true

Try {

$dp.RefreshNow = $true

$dp.Put() | Out-Null

$dpName + ” – ” + $packageID

}

Catch [Exception]

{

return $_.Exception.Message

}

}

}

If ($dpFound -eq $false)

{

Throw “No results returned.”

}

}

How to use

Run from powershell : Usage: Refresh-SpecificDP -siteCode xxx -packageID xxxxxxxx -dpName xxxx

Steps followed to execute above powershell command.

1. Open Powershell as Administrator

2. Type “Set-ExecutionPolicy Bypass” and Enter

3. Import SCCM Module “Import-Module “console install path\bin\ConfigurationManager.psd1”

4. Run Saved Funtion “. .\path to file\filename.ps1”

5. Refresh-SpecificDP -siteCode xxx -packageID xxxxxxxx -dpName xxxx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: