MSEndpointMgr / ConfigMgr

Microsoft Endpoint Configuration Manager scripts and tools
633 stars 281 forks source link

Get Latest Software Update Group CI_ID made by Automatic Deployment Rule #158

Closed LinkOps closed 4 years ago

LinkOps commented 5 years ago

This is in relation to the following blog post you made and more a suggestion for improvement.

https://www.scconfigmgr.com/2018/07/12/send-your-patching-manifest-to-teams/

I have an ADR setup to make a new Software Update Group everytime it runs and therefore the Software Update group changes month on month. To get the Latest Software Update Group made by the Automatic Deployment Rule you can use the following:

$ADR = "Microsoft Product Updates ADR"

$SUGInfo = Get-CMSoftwareUpdateGroup -verbose:$false | Where LocalizedDescription -eq $ADR | Sort-Object DateCreated -Descending | Select-Object -First 1 | Select-Object -ExpandProperty CI_ID

This is likely not the best way to do it but I'm new to Powershell so feel free to update as needed to make it more efficient.