Created
May 6, 2019 15:47
-
-
Save CodyMathis123/94896d3e86929f069949709757d5b2cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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