Public/Functions/split/Get-WSUSXML.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
<#
.SYNOPSIS Returns an Array of Microsoft Updates .DESCRIPTION Returns an Array of Microsoft Updates contained in the local WSUS Catalogs .LINK https://osd.osdeploy.com/ .PARAMETER GridView Displays the results in GridView with -PassThru .PARAMETER Silent Hide the Current Update Date information #> function Get-WSUSXML { [CmdletBinding()] PARAM ( #Filter by Catalog Property [Parameter(Position = 0)] [ValidateSet( 'All', 'Enablement', 'FeatureUpdate', 'Office', 'Office 2010 32-Bit', 'Office 2010 64-Bit', 'Office 2013 32-Bit', 'Office 2013 64-Bit', 'Office 2016 32-Bit', 'Office 2016 64-Bit', 'Windows', 'Windows 10', 'Windows 10 Dynamic Update', 'Windows 11', 'Windows 11 Dynamic Update', 'Windows Client', 'Windows Server' )] [Alias('Format')] [string]$Catalog = 'All', #Filter by UpdateArch Property [ValidateSet('x64','x86')] [string]$UpdateArch, #Filter by UpdateBuild Property [ValidateSet(1507,1511,1607,1703,1709,1803,1809,1903,1909,2004,'20H2','21H1','21H2','22H2')] [string]$UpdateBuild, #Filter by UpdateGroup Property [ValidateSet('AdobeSU','DotNet','DotNetCU','LCU','Optional','SSU')] [string]$UpdateGroup, #Filter by UpdateOS Property [ValidateSet('Windows 11','Windows 10','Windows Server')] [string]$UpdateOS, #Display the results in GridView [System.Management.Automation.SwitchParameter]$GridView, #Don't display the Module Information [System.Management.Automation.SwitchParameter]$Silent ) #=================================================================================================== # Defaults #=================================================================================================== $WSUSXMLCatalogPath = "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\WSUSXML" $WSUSXMLVersion = $($MyInvocation.MyCommand.Module.Version) #=================================================================================================== # Catalogs #=================================================================================================== $WSUSXMLCatalogs = Get-ChildItem -Path "$WSUSXMLCatalogPath\*" -Include "*.xml" -Recurse | Select-Object -Property * switch ($Catalog) { 'Enablement' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Enablement'}} 'FeatureUpdate' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'FeatureUpdate'}} 'Office' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office'}} 'Office 2010 32-Bit' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office 2010'}} 'Office 2010 64-Bit' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office 2010'}} 'Office 2013 32-Bit' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office 2013'}} 'Office 2013 64-Bit' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office 2013'}} 'Office 2016 32-Bit' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office 2016'}} 'Office 2016 64-Bit' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Office 2016'}} 'Windows' { $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Windows'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Enablement'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'FeatureUpdate'} } 'Windows Client' { $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Windows'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Dynamic Update'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Enablement'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'FeatureUpdate'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Server'} } 'Windows 10' { $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Windows 10'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Dynamic Update'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Enablement'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'FeatureUpdate'} } 'Windows 11' { $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Windows 11'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Dynamic Update'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'Enablement'} $WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -notmatch 'FeatureUpdate'} } 'Windows 10 Dynamic Update' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -eq $Catalog}} 'Windows 11 Dynamic Update' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -eq $Catalog}} 'Windows Server' {$WSUSXMLCatalogs = $WSUSXMLCatalogs | Where-Object {$_.BaseName -match 'Windows Server'}} } #=================================================================================================== # Update Information #=================================================================================================== if (!($Silent.IsPresent)) { Write-Verbose "WSUSXML $WSUSXMLVersion $Catalog" -Verbose } #=================================================================================================== # Variables #=================================================================================================== $WSUSXML = @() #=================================================================================================== # Import Catalog XML Files #=================================================================================================== foreach ($WSUSXMLCatalog in $WSUSXMLCatalogs) { $WSUSXML += Import-Clixml -Path "$($WSUSXMLCatalog.FullName)" } #=================================================================================================== # Standard Filters #=================================================================================================== $WSUSXML = $WSUSXML | Where-Object {$_.FileName -notlike "*.exe"} $WSUSXML = $WSUSXML | Where-Object {$_.FileName -notlike "*.psf"} $WSUSXML = $WSUSXML | Where-Object {$_.FileName -notlike "*.txt"} $WSUSXML = $WSUSXML | Where-Object {$_.FileName -notlike "*delta.exe"} $WSUSXML = $WSUSXML | Where-Object {$_.FileName -notlike "*express.cab"} if ($Catalog -match 'Office') { if ($Catalog -match '32-Bit') { $WSUSXML = $WSUSXML | Where-Object {$_.Title -match '32-Bit'} } if ($Catalog -match '64-Bit') { $WSUSXML = $WSUSXML | Where-Object {$_.Title -notmatch '64-Bit'} } } #=================================================================================================== # Filter #=================================================================================================== if ($UpdateArch) {$WSUSXML = $WSUSXML | Where-Object {$_.UpdateArch -eq $UpdateArch}} if ($UpdateBuild) {$WSUSXML = $WSUSXML | Where-Object {$_.UpdateBuild -eq $UpdateBuild}} if ($UpdateGroup) {$WSUSXML = $WSUSXML | Where-Object {$_.UpdateGroup -eq $UpdateGroup}} if ($UpdateOS) {$WSUSXML = $WSUSXML | Where-Object {$_.UpdateOS -eq $UpdateOS}} #=================================================================================================== # Sorting #=================================================================================================== #$WSUSXML = $WSUSXML | Sort-Object -Property @{Expression = {$_.CreationDate}; Ascending = $false}, Size -Descending $WSUSXML = $WSUSXML | Sort-Object -Property CreationDate -Descending if ($Catalog -eq 'FeatureUpdate') {$WSUSXML = $WSUSXML | Sort-Object -Property Title} #=================================================================================================== # GridView #=================================================================================================== if ($GridView.IsPresent) { $WSUSXML = $WSUSXML | Out-GridView -PassThru -Title 'Select Updates to Return' } #=================================================================================================== # Return #=================================================================================================== Return $WSUSXML } |