Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $computer = $env:COMPUTERNAME
- $ErrorActionPreference = "Continue"
- $ResourceID = (Get-WmiObject -Class SMS_R_System -Namespace root\SMS\site_SITECODE -ComputerName #SITESERVER# | Where-Object {$_.name -eq "$computer"}).resourceid
- $CollectionIDs = (Get-WmiObject -Class SMS_DeploymentInfo -Namespace root\SMS\site_SITECODE -ComputerName #SITESERVER# | Where-Object {$_.DeploymentType -eq "7" -and $_.collectionname -ne "All Unknown Computers"}).CollectionID
- $DirectRule = [wmiclass]("\\#SITESERVER#\ROOT\SMS\site_SITECODE:SMS_CollectionRuleDirect")
- $DirectRule.Properties["ResourceClassName"].Value = "SMS_R_System"
- $DirectRule.Properties["ResourceID"].Value = "$ResourceID"
- $DirectRule.Properties["RuleName"].Value = "$computer"
- foreach ($CollectionID in $CollectionIDs) {
- (Get-WmiObject -Class SMS_Collection -Namespace root\SMS\site_SITECODE -ComputerName #SITESERVER# | Where-Object {$_.collectionid -eq "$CollectionID"}).DeleteMembershipRule($DirectRule)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement