SCCM PowerShell Script to Check for Local DP (Get-SCCMClientHasLocalDP)

As announced at HASMUG September 2011 I have developed 4 PowerShell cmdlet’s to add on to Rikard Ronnkvist’s PowerShell module. They are not officially published yet but here is the one that checks to see if the target machine has a local SCCM distribution point (provided your AD sites are dialed in). More community contributed content to come!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Function Get-SCCMClientHasLocalDP {
    [CmdletBinding()]
    PARAM (
        [Parameter(Mandatory=$true, HelpMessage="SCCM Server")][Alias("Server","SmsServer")][System.Object] $SccmServer,
        [Parameter(Mandatory=$true, HelpMessage="ClientName",ValueFromPipeline=$true)][String] $clientName,
		[Parameter(Mandatory=$false,HelpMessage="Credentials to use" )][System.Management.Automation.PSCredential] $credential = $null
    )
 
    PROCESS {
		$DP = $false
		if ($credential -eq $null) {
			$client = Get-SCCMObject -sccmServer $SccmServer -class SMS_R_System -Filter "Name = '$($clientName)'"
			if (-not $client) {
				throw "Client does not exist in SCCM. Please check your spelling"
			}
			$Filter = "SMS_R_System.ADSiteName = '$($client.ADSiteName)' and Name IN (Select ServerName FROM SMS_DistributionPointInfo)"
        	$DP = Get-SCCMObject -sccmServer $SccmServer -class SMS_R_System -Filter $Filter
		} else {
			$client = Get-SCCMObject -sccmServer $SccmServer -class SMS_R_System -Filter "Name = '$($clientName)'" -credential $credential
			if (-not $client) {
				throw "Client does not exist in SCCM. Please check your spelling"
			}
			$Filter = "SMS_R_System.ADSiteName = '$($client.ADSiteName)' and Name IN (Select ServerName FROM SMS_DistributionPointInfo)"
        	$DP = Get-SCCMObject -sccmServer $SccmServer -class SMS_R_System -Filter $Filter -credential $credential
		}
 
		if ($DP) {
 			return $true
		} else {
			return $false
		}
    }
}

This site uses Akismet to reduce spam. Learn how your comment data is processed.