Tuesday, July 12, 2011

How to remove locks on packages in distribution points list for a package


Sometimes you see lock on a DP for a particular package. This generally happens after a migration, or incorrectly creating a package.

To fix this, run the below query on your central database:

UPDATE Pkgservers set SourceSite = 'central site code' where PkgID = 'package id' and SiteCode = 'XXX'

Monday, July 11, 2011

Script to remove the list of packages from DPs in SCCM

' Pratik Pawar
' This script will remove the packages given in text file listofpackagesToDelete.txt to that DP


Option Explicit
'On Error Resume Next

Dim objFSO
Dim objTextFile
Dim strNextLine
Dim arrServiceList

Dim WbemServices
Dim loc

Dim DPs, DP

Set loc = CreateObject("WbemScripting.SWbemLocator")
Set WbemServices = loc.ConnectServer( , "root\SMS\site_999")

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("listofpackagesToDelete.txt", ForReading)


Do Until objTextFile.AtEndOfStream
    'read the next line
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , "    ")

    'arrServiceList(0) = packageid, arrServiceList(1) = DP

    Set DPs = wbemServices.ExecQuery("Select * From SMS_DistributionPoint WHERE PackageID='" & arrServiceList(0) & "' AND SiteCode = '" & arrServiceList(1) & "'")

    For Each DP In DPs
        Wscript.Echo  DP.ServerNALPath
        DP.Delete_
    Next
Loop