Skip to content

Instantly share code, notes, and snippets.

@AfroThundr3007730
Last active March 31, 2024 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AfroThundr3007730/40b14b146fa21f1783c85e2054c83ed0 to your computer and use it in GitHub Desktop.
Save AfroThundr3007730/40b14b146fa21f1783c85e2054c83ed0 to your computer and use it in GitHub Desktop.
Finds SCCM management point in AD based on site code
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 {}
}
}
@AfroThundr3007730
Copy link
Author

Inspired by this blog post.

@AfroThundr3007730
Copy link
Author

Updated version available in my HelperFunctions module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment