Skip to content

Instantly share code, notes, and snippets.

@CodyMathis123
Created May 6, 2019 15:47
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 CodyMathis123/94896d3e86929f069949709757d5b2cc to your computer and use it in GitHub Desktop.
Save CodyMathis123/94896d3e86929f069949709757d5b2cc to your computer and use it in GitHub Desktop.
$getWmiObjectSplat = @{
Query = "SELECT LocalizedDisplayName FROM SMS_SoftwareUpdate WHERE LocalizedDisplayName LIKE 'Office 365 Client Update - $Channel%$Bitness%' AND IsDeployed = '1' AND IsLatest = '1'"
ComputerName = $SMSProvider
Namespace = "root\sms\site_$SiteCode"
}
$365Patches = Get-WmiObject @getWmiObjectSplat | Select-Object -ExpandProperty LocalizedDisplayName
if ($365Patches.Count -gt 0) {
$Regex = "\(Build ([0-9]+\.[0-9]+)\)"
[double[]]$Builds = foreach ($Value in $365Patches) {
[regex]::Match($Value, $Regex).Groups[1].Value
}
$LatestBuild = ($Builds | Sort-Object | Select-Object -Last 1).ToString()
$FullBuildNumber = [string]::Format('16.0.{0}', $LatestBuild)
Write-Output "Identified O365 [Version=$FullBuildNumber] as the latest deployed version for [Channel=$Channel] - This value will be used to update all XML"
}
else {
Write-Error -Message "Failed to identify Office 365 version based on the input. This likely means you are not deploying updates for the specified architecture and update channel." -ErrorAction Stop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment