Last active
March 31, 2024 18:24
-
-
Save AfroThundr3007730/40b14b146fa21f1783c85e2054c83ed0 to your computer and use it in GitHub Desktop.
Finds SCCM management point in AD based on site code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-SMSManagementPoint { | |
<# .SYNOPSIS | |
Finds SCCM management point based on site code #> | |
Param( | |
# The site code to search | |
[Parameter(Mandatory)] | |
[string]$SiteCode | |
) | |
return [adsisearcher]::new( | |
[adsi]('LDAP://CN=Partitions,' + ( | |
[adsi]'LDAP://RootDSE').get('configurationNamingContext') | |
), | |
'(&(objectCategory=crossref)(netbiosname=*))' | |
).findAll().Properties.ncname.forEach{ | |
Try { | |
[adsisearcher]::new( | |
[adsi]('LDAP://CN=System Management,CN=System,' + $_), | |
"(&(ObjectClass=mSSMSManagementPoint)(Name=SMS-MP*-$SiteCode-*))" | |
).findAll().Properties.mssmsmpname | |
} | |
Catch {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by this blog post.