Enable AutoProvision Policy with Powershell
Hello,
Are you working with Out of Band Management (OOB) in ConfigMgr / SCCM? Instead of waiting for SCCM policy to apply to a client, would you like to force the auto-provisioning policy to apply on-demand? If so, then you've come to the right place. Here is some Powershell code that will enable auto-provisioning on an SCCM client.
$OobSettings = [wmiclass]ā€¯root\ccm\policy\machine\actualconfig:CCM_OutOfBandManagementSettingsā€¯
$OobSettingsInstance = $OobSettings.CreateInstance()
$OobSettingsInstance.AutoProvision = $True
$OobSettingsInstance.SiteSettingsKey = 1
$OobSettingsInstance.Put()-Trevor Sullivan
Powershell - Compare Active Directory Groups
Here is a Powershell script that compares two Active Directory groups, and determines the differences between the account membership of them.
$DN1 = "CN=Group1,OU=Groups,OU=Accounts,DC=subdomain,DC=mydomain,DC=local"
$DN2 = "CN=Group2,OU=Groups,OU=Accounts,DC=subdomain,DC=mydomain,DC=local"
$Group1 = [adsi]"LDAP://$DN1"
$Group2 = [adsi]"LDAP://$DN2"
ForEach ($User in $Group1.member)
{
if ($Group2.member -contains $User)
{
Write-Host "$User belongs to $($Group2.cn)"
}
else
{
Write-Host "$User does not belong to $($Group2.cn)"
}
}-Trevor Sullivan
Powershell - Domain Distinguished Name
Hello,
The two lines below allow you to use the LDAP "RootDSE" object to dynamically access the root of an Active Directory (AD) domain, from a domain member. The
defaultNamingContext attribute on the RootDSE object contains the full distinguished name of the AD domain.
$RootDSE = [adsi]"LDAP://RootDSE"
$DomainRoot = [adsi]"$($RootDSE.DefaultNamingContext)"Now that you have a reference to the domain root in the $DomainRoot variable, you can perform any operations you need to from that point. For example, to enumerate the children of the domain root, simply type the following at your interactive Powershell command prompt:
$DomainRoot.psbase.Children-Trevor Sullivan