question

ShijinMohammed-5429 avatar image
0 Votes"
ShijinMohammed-5429 asked saldana-msft edited

PowerShell Script to distribute packages to DPs if it's not

Hi

I have a requirement to write a PowerShell script to,

  1. Read a list of DPs (Know how to do it)

  2. And Read a list of packages

  3. And then for each DP it will check if each package is already distributed to the DP

  4. If it is it does nothing

  5. If it isn’t, it will distribute the package to the DP.

I'm able to figure out steps 1,2, 4 & 5. I need your help to get the PS cmdlet to check whether the package is distributed or not.

Shijin M



windows-server-powershellmem-cm-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShijinMohammed-5429 avatar image
0 Votes"
ShijinMohammed-5429 answered ShijinMohammed-5429 edited

Thanks
Re-wrote the script like below.

$x = $null
$x = Get-CMDeploymentPackage -DistributionPointName "DPName" -DeploymentPackageName "AppName"
If ($x -ne $null)
{
Write-Host "Distributed Already";
}
Else
{
Write-Host "Not yet Distributed";
}

Thanks!!









5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
1 Vote"
RichMatheisen-8856 answered RichMatheisen-8856 edited

See the help for the Get-CMDeploymentPackage.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
1 Vote"
IanXue-MSFT answered

Hi,

The Get-CMDeploymentPackage cmdlet gets information about deployment packages on a distribution point.

 Get-CMDeploymentPackage -DistributionPointName "YourDPName" -DeploymentPackageName "YourPackageName"

Get-CMDeploymentPackage
https://docs.microsoft.com/en-us/powershell/module/configurationmanager/get-cmdeploymentpackage?view=sccm-ps

Best Regards,
Ian

============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShijinMohammed-5429 avatar image
0 Votes"
ShijinMohammed-5429 answered

Hi Ian,

Thanks!!

It gives output if the package is distributed.

Is it possible to get an output like

"Yes" - If the package is distributed.
"No" - If the package is not distributed.

Thanks!!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
1 Vote"
RichMatheisen-8856 answered RichMatheisen-8856 edited

Try this:

 Try{
     $x = Get-CMDeploymentPackage -DistributionPointName "YourDPName" -DeploymentPackageName "YourPackageName" -ErrorAction STOP
     "Yes"
 }
 Catch{
     "No"
 }
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.