Friday, July 3, 2015

Query for SCCM 2012 DP Status Overview

SCCM Distribution points as we may know is an important part of an SCCM Setup.
A distribution point which is not operational due to various reasons would have repercussion effects on a package deployment. Issues that arises may be from the perspective of network bandwidth etc.
It is always welcome to have a single pane view of teh status of anything that we need to have visibility on and this includes the status of the DPs.
The SQL query below will enable you to gain that "Single Pane" view from the available disk space as well as the settings that are configured which is inclusive of Transfer rate among others.

SELECT [ServerName]
     ,IB.[SiteCode]
      ,[Priority]
      ,[TransferRate]
      ,[IsProtected]
      ,[PreStagingAllowed]
      ,[ResourceType]
      ,[SiteName]
      ,[DPFlags]
      ,[Name]
      ,[ID]
      ,[IsPXE]
      ,[IsActive]
      ,[ResponseDelay]
      ,[UdaSetting]
      ,[BindPolicy]
      ,[SupportUnknownMachines]
      ,[PXEPassword]
      ,[GroupCount]
      ,[HasRelationship]
      ,[InternetFacing]
      ,[HealthCheckEnabled]
      ,[HealthCheckPriority]
      ,[HealthCheckSchedule]
      ,[AddressScheduleEnabled]
      ,[RateLimitsEnabled]
     , DI.Drive
,DI.PercentFree
,DI.BytesFree
  FROM [CM_C00].[dbo].[v_DistributionPointInfoBase] IB
  left join dbo.v_DistributionPointDriveInfo DI on DI.NALPath = IB.NALPath

Thursday, June 18, 2015

Mass deleting Obsolete SCCM Clients

I would believe that every SCCM Admin would at some point of time need to cleanup obsolete SCCM Client objects from the SCCM Sites.
Most of the time when this is needed, all you will be provided is a list of the machines that are no longer in Active Directory and these SCCM Clients has to be purged from SCCM.
For this purpose, the below VBS will do just that

ON ERROR RESUME NEXT
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
I = 0

strServer=InputBox("Enter Site Server Nmae",,"SCCM-Pri-Site-Server")
strSiteCode=InputBox("Enter Site Code",,"P01")


Set fso = CreateObject("Scripting.FileSystemObject")
strfolder = fso.GetParentFolderName(wscript.ScriptFullName) 

'You may replace obsolete.txt with any text file name you prefer. The contents of this file is used to list out the SCCM clients that are to be purged.
FileName = strfolder & "\Obsolete.txt"
'Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = fso.OpenTextFile(Filename,ForReading)
strmachine = objFile.ReadAll
objFile.Close


arrcomp = split(strmachine, vbCrLf)
if isnull(strmachine) then
wscript.echo "No Machine info"
Else
For each strmachine in arrcomp
strcomputer = strmachine
Set locator = CreateObject("WbemScripting.SWbemLocator")
Set WbemServices1 = locator.ConnectServer(strServer,"root\SMS\site_" & strSiteCode)
ResID = getResID(strComputer, WbemServices1)


Set sResource = WbemServices1.Get("SMS_R_System='" & ResID & "'")
sResource.Delete_
Set sResource = Nothing
I = I +1
next

wscript.echo "Housekeep Done! A total of " & I & " obsolete SCCM records were deleted"
End if

Function getResID(strComputer, oWbem)
strQry = "Select ResourceID from SMS_R_System where Name=" & "'" & strComputer & "'"
Set objEnumerator = oWbem.ExecQuery(strQry)
If Err <> 0 Then
GetResID = 0
Exit Function
End If
For Each objInstance in objEnumerator
For Each oProp in objInstance.Properties_
GetResID = oProp.Value
Next
Next
Set objEnumerator = Nothing
End Function

Tuesday, June 9, 2015

Monitoring GPO changes using SCOM

It is pretty common for AD admins to want to be able to monitor changes to GPO via SCOM.
Of course, there are events that are logged for every change made to any GPO.
The real challenge is that we will not be able to know which GPO was changed without having to go through an extensive search through the GPMC or by means of powershell.
What is required is that the SCOM alert should include the name of the GPO so that the efforts and time of the IT Admins are keep to the minimum.

The below is an article from the community that will enable you to do just that
Click here