Skip to content

Instantly share code, notes, and snippets.

View Disabled devices in Active Directory
#How many disabled devices in Active Directory
Get-ADComputer -Filter {(Enabled -eq $False)} | Measure-Object
View AD devices count
#How many devices in Active Directory
Get-ADComputer -Filter * | Measure-Object
View Invoke-WsusServerCleanup
Invoke-WsusServerCleanup `
-CleanupObsoleteComputers `
-CleanupObsoleteUpdates `
-CleanupUnneededContentFiles `
-CompressUpdates `
-DeclineExpiredUpdates `
-DeclineSupersededUpdates
View Get-ConfigMgrResourceFQDN
$CollectionMembers = Get-CMCollectionMember -CollectionId PS10008E
foreach($Member in $CollectionMembers){
$ResourceQuery = Get-CimInstance `
-Namespace 'Root\SMS\Site_PS1' `
-Query "Select * from SMS_R_System where ResourceID=$($Member.ResourceID)"
$ResourceQuery.ResourceNames
}
View Consolidate-ConfigMgrSWGroups.ps1
Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")
$CMSite = Get-PSProvider -PSProvider CMSITE
Set-Location -Path "$($CMSite.Drives.Name):\"
# 2017 Software Update Groups
#Create new Software Update Group for 2017 Updates
New-CMSoftwareUpdateGroup -Name 'SUM WRK 2017 Compliance'
#Get 2017 Software Updates Groups
$SWGroups = Get-CMSoftwareUpdateGroup -Name 'SUM WRK 2017*' -ForceWildcardHandling |
@Kaidja
Kaidja / Clean-CMSoftwareUpdateGroup
Created Dec 6, 2017
Cleanup ConfigMgr Software Update Group
View Clean-CMSoftwareUpdateGroup
Set-CMSoftwareUpdateGroup -Name 'SUM WRK 2017 11 November' -ClearExpiredSoftwareUpdate -ClearSupersededSoftwareUpdate