$ErrorActionPreference = "SilentlyContinue"
$SCCMServer = '
$SMSSitecode = "YourSiteCode"
$DP = "YourDP"
$pkgs = Get-WMIObject -ComputerName $SCCMServer -Namespace "root\sms\site_$SMSSitecode" -Query "Select * From SMS_DistributionPoint WHERE ServerNalPath like '%$DP%' and SourceSite = '$smssidecode'"
foreach ($pkg in $pkgs){write-host $pkg.PackageID;$ID.Delete()}
If you want to find out the ServerNalPath of the servers replace the code with the below. If you have PXE shares, you may end up accidentally deleting something you don't want but those shares shouldn't be holding software packages. Enter a packageID to limit the results or it will pull the ServerNALPath from all packageIDs.
$pkgs = Get-WMIObject -ComputerName $SCCMServer -Namespace "root\sms\site_$SMSSitecode" -Query "Select * From SMS_DistributionPOint WHERE PackageID = '$packageid' and SourceSite = 'XXX'"
foreach ($pkg in $pkgs){write-host $pkg.ServerNalPath}
Replace XXX with your site code above.
Good resources for scripting in general and SCCM related.
https://technet.microsoft.com/en-us/scriptcenter/bb410849.aspx
https://msdn.microsoft.com/en-us/library/cc145334.aspx
No comments:
Post a Comment