Last active
November 12, 2019 16:23
-
-
Save altrive/5268181 to your computer and use it in GitHub Desktop.
Revisions
-
altrive revised this gist
Apr 13, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,6 @@ $params=@{ #Remove files that updated periodically Get-ChildItem $params.DownloadFolder | where Name -Like "am_delta_*.exe" | Remove-Item #Windows Defender Definition Get-ChildItem $params.DownloadFolder | where Name -Like "im*.cab" | Remove-Item #IME patch Get-ChildItem $params.DownloadFolder | where Name -Like "windows-kb890830-*.exe" | Remove-Item #Windows Malicious Software Removal Tool Start-DownloadWindowsUpdateFile @params -Verbose ``` -
altrive revised this gist
Apr 13, 2013 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,8 @@ param( #Append to download list $url = $content.DownloadURL $fileName = [IO.Path]::GetFileName($url) $downloadList += [pscustomobject]@{Title=$title;LastDeploymentChangeTime=$date ;DownloadURL=$url;IsInstalled=$isInstalled;RebootRequired=$rebootRequired;FileName=$fileName} } } } @@ -67,6 +68,8 @@ param( Write-Verbose ("WindowsUpdate check completed: {0} files found" -f $results.Count) #$results | select Title,FileName, LastDeploymentChangeTime | Format-List #Start Download Files Write-Verbose ("Download files started...") foreach($update in $results) -
altrive revised this gist
Apr 13, 2013 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,9 @@ $params=@{ WindowsUpdateFilte = "IsHidden=0" } #Remove files that updated periodically Get-ChildItem $params.DownloadFolder | where Name -Like "am_delta_*.exe" | Remove-Item #Windows Defender Definition Get-ChildItem $params.DownloadFolder | where Name -Like "im*.cab" | Remove-Item #IME patch Get-ChildItem $params.DownloadFolder | where Name -Like "windows-kb890830-*.cab" | Remove-Item #Windows Malicious Software Removal Tool Start-DownloadWindowsUpdateFile @params -Verbose ``` -
altrive revised this gist
Apr 13, 2013 . 2 changed files with 5 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,10 +7,6 @@ param( [Parameter(Mandatory=$True)] [string] $Filter ) $objSession = New-Object -ComObject "Microsoft.Update.Session" $objSearcher = $objSession.CreateUpdateSearcher() $results = $objSearcher.Search($Filter) @@ -48,10 +44,11 @@ function Start-DownloadWindowsUpdateFile [Cmdletbinding()] param( [string] $TargetComputer, $Credential, [string] $DownloadFolder, [string] $WindowsUpdateFilter ) if(!(Test-Path $DownloadFolder)) { Write-Error "Destination folder not found!" } @@ -64,11 +61,8 @@ param( } else { Write-Verbose ("Search WindowsUpdate for remote computer({0})..." -f $TargetComputer) $results = Invoke-Command -Computer $TargetComputer -Credential $Credential -ScriptBlock ${function:Get-WindowsUpdateFileList} -ArgumentList $WindowsUpdateFilter } Write-Verbose ("WindowsUpdate check completed: {0} files found" -f $results.Count) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,8 @@ and download files to network share. ``` powershell $params=@{ TargetComputer = "172.16.100.2" Credential = Get-Credential -UserName "localhost\Administrator" -Message "Enter credential" DownloadFolder = "\\172.16.0.1\Shared\Images\WindowsUpdate\Windows8" WindowsUpdateFilte = "IsHidden=0" } -
altrive revised this gist
Apr 4, 2013 . 2 changed files with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -56,6 +56,7 @@ param( Write-Error "Destination folder not found!" } if($TargetComputer -eq $env:ComputerName) { Write-Verbose ("Search WindowsUpdate for local computer...") @@ -80,11 +81,11 @@ param( $filePath = Join-Path $DownloadFolder $fileName if(Test-Path $filePath) { Write-Verbose "`tSkip already exists patch: $fileName" continue } Write-Verbose "`tStart download patch: $fileName" $params = @{ Source = $update.DownloadURL DisplayName = $update.Title This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,9 +12,12 @@ and download files to network share. ``` powershell $params=@{ TargetComputer = "172.16.100.57" DownloadFolder = "\\172.16.0.1\Shared\Images\WindowsUpdate\Windows8" WindowsUpdateFilte = "IsHidden=0" } #Remove WindowsDefender Definition File(Updated Daily) Get-ChildItem $params.DownloadFolder | where Name -Like "am_delta_*.exe" | Remove-Item Start-DownloadWindowsUpdateFile @params -Verbose ``` -
altrive revised this gist
Apr 3, 2013 . 2 changed files with 60 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ #Requires –Version 3 #Get WindowsUpdate List for offline patch function Get-WindowsUpdateFileList { @@ -12,8 +14,6 @@ param( $objSession = New-Object -ComObject "Microsoft.Update.Session" $objSearcher = $objSession.CreateUpdateSearcher() $results = $objSearcher.Search($Filter) $downloadList =@() foreach($update in $results.Updates) @@ -41,4 +41,57 @@ param( } } return $downloadList } function Start-DownloadWindowsUpdateFile { [Cmdletbinding()] param( [string] $TargetComputer, [string] $DownloadFolder, [string] $WindowsUpdateFilter ) if(!(Test-Path $destination)) { Write-Error "Destination folder not found!" } if($TargetComputer -eq $env:ComputerName) { Write-Verbose ("Search WindowsUpdate for local computer...") $results = Get-WindowsUpdateFileList $WindowsUpdateFilter } else { if($cred -eq $null){ $cred = Get-Credential -UserName "localhost\Administrator" -Message "Enter credential" } Write-Verbose ("Search WindowsUpdate for remote computer({0})..." -f $TargetComputer) $results = Invoke-Command -Computer $TargetComputer -Credential $cred -ScriptBlock ${function:Get-WindowsUpdateFileList} -ArgumentList $WindowsUpdateFilter } Write-Verbose ("WindowsUpdate check completed: {0} files found" -f $results.Count) #Start Download Files Write-Verbose ("Download files started...") foreach($update in $results) { $fileName = [IO.Path]::GetFileName($update.DownloadURL) $filePath = Join-Path $DownloadFolder $fileName if(Test-Path $filePath) { Write-Verbose "Skip already exists patch: $fileName" continue } Write-Verbose "Start download patch: $fileName" $params = @{ Source = $update.DownloadURL DisplayName = $update.Title Description = $update.DownloadURL Destination = $DownloadFolder } Start-BitsTransfer @params } Write-Verbose ("Download files completed...") } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,35 +11,10 @@ following sample check WindowsUpdate for specified computer, and download files to network share. ``` powershell $params=@{ TargetComputer = "172.16.100.53" DownloadFolder = "\\172.16.0.1\Shared\Images\WindowsUpdate\Windows8" WindowsUpdateFilte = "IsHidden=0" } Start-DownloadWindowsUpdateFile @params -Verbose ``` -
altrive revised this gist
Apr 2, 2013 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,15 +11,27 @@ following sample check WindowsUpdate for specified computer, and download files to network share. ``` powershell #Requires –Version 3 #Requires –Modules PShould $target = $env:COMPUTERNAME #$filter = "IsAssigned=1 and IsHidden=0" $filter = "IsHidden=0" if($cred -eq $null){ $cred = Get-Credential -UserName "localhost\Administrator" -Message "Enter credential" } #Get WindowsUpdate file list for target computer(if not domain environment -Credential parameter needed) $results = Invoke-Command -Computer $target -Credential $cred -ScriptBlock ${function:Get-WindowsUpdateFileList} -ArgumentList $filter #Download files $destination= "\\172.16.0.1\Shared\Images\WindowsUpdate\WindowsServer2012" if(!(Test-Path $destination)){ Write-Error "Destination folder not found!" } foreach($update in $results) { $params = @{ -
altrive revised this gist
Apr 1, 2013 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,14 +27,15 @@ param( { foreach($content in $bundledUpdate.DownloadContents) { #if($url.Contains("-express_") -or $url.Contains("-delta_") -or $url.EndsWith(".psf")) if($content.IsDeltaCompressedContent) { #Skip express package(Delta Compressed Package) and .psf file continue } #Append to download list $url = $content.DownloadURL $downloadList += [pscustomobject]@{Title=$title;LastDeploymentChangeTime=$date ;DownloadURL=$url;IsInstalled=$isInstalled;RebootRequired=$rebootRequired} } } -
altrive revised this gist
Mar 29, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,7 @@ param( $title = $update.Title $date = $update.LastDeploymentChangeTime $isInstalled = $update.IsInstalled $rebootRequired = $update.RebootRequired foreach($bundledUpdate in $update.BundledUpdates) { @@ -34,7 +35,7 @@ param( } #Append to download list $downloadList += [pscustomobject]@{Title=$title;LastDeploymentChangeTime=$date ;DownloadURL=$url;IsInstalled=$isInstalled;RebootRequired=$rebootRequired} } } } -
altrive revised this gist
Mar 29, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ param( foreach($content in $bundledUpdate.DownloadContents) { $url = $content.DownloadURL if($url.Contains("-express_") -or $url.Contains("-delta_") -or $url.EndsWith(".psf")) { #Skip express package(Delta Compressed Package) and .psf file continue -
altrive revised this gist
Mar 29, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,8 @@ and download files to network share. ``` powershell $target = $env:COMPUTERNAME #$filter = "IsAssigned=1 and IsHidden=0" $filter = "IsHidden=0" #Get WindowsUpdate file list for target computer(if not domain environment -Credential parameter needed) $results = Invoke-Command -Computer $target -ScriptBlock ${function:Get-WindowsUpdateFileList} -ArgumentList $filter -
altrive revised this gist
Mar 29, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ and download files to network share. $target = $env:COMPUTERNAME $filter = "IsAssigned=1 and IsHidden=0" #Get WindowsUpdate file list for target computer(if not domain environment -Credential parameter needed) $results = Invoke-Command -Computer $target -ScriptBlock ${function:Get-WindowsUpdateFileList} -ArgumentList $filter #Download files -
altrive revised this gist
Mar 29, 2013 . 2 changed files with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #Get WindowsUpdate List for offline patch function Get-WindowsUpdateFileList { param( [Parameter(Mandatory=$True)] @@ -20,6 +20,7 @@ param( { $title = $update.Title $date = $update.LastDeploymentChangeTime $isInstalled = $update.IsInstalled foreach($bundledUpdate in $update.BundledUpdates) { @@ -33,7 +34,7 @@ param( } #Append to download list $downloadList += [pscustomobject]@{Title=$title;LastDeploymentChangeTime=$date ;DownloadURL=$url;IsInstalled=$isInstalled} } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ $target = $env:COMPUTERNAME $filter = "IsAssigned=1 and IsHidden=0" #Get WindowsUpdate file list for target computer $results = Invoke-Command -Computer $target -ScriptBlock ${function:Get-WindowsUpdateFileList} -ArgumentList $filter #Download files $destination= "\\172.16.0.1\Shared\Images\WindowsUpdate\WindowsServer2012" -
altrive created this gist
Mar 29, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #Get WindowsUpdate List for offline patch function Get-WindowsUpdateList { param( [Parameter(Mandatory=$True)] [string] $Filter ) <# #Need CreateInstance to kick WindowsUpdate from Remote Computer? $objSession = [Activator]::CreateInstance([Type]::GetTypeFromProgID("Microsoft.Update.Session",$env:ComputerName)) #> $objSession = New-Object -ComObject "Microsoft.Update.Session" $objSearcher = $objSession.CreateUpdateSearcher() $results = $objSearcher.Search($Filter) #Write-Debug $results.Updates.Count $downloadList =@() foreach($update in $results.Updates) { $title = $update.Title $date = $update.LastDeploymentChangeTime foreach($bundledUpdate in $update.BundledUpdates) { foreach($content in $bundledUpdate.DownloadContents) { $url = $content.DownloadURL if($url.Contains("-express_") -or $url.EndsWith(".psf")) { #Skip express package(Delta Compressed Package) and .psf file continue } #Append to download list $downloadList += [pscustomobject]@{Title=$title;LastDeploymentChangeTime=$date ;DownloadURL=$url} } } } return $downloadList } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ Summary ---- PowerShell cmdlets to check WindowsUpdate and return patch list. This script is intended for offline Windows patching. (MBSA 2.2 currently not support Windows 8/Windows Server 2012) Usage --- following sample check WindowsUpdate for specified computer, and download files to network share. ``` powershell $target = $env:COMPUTERNAME $filter = "IsAssigned=1 and IsHidden=0" #Get WindowsUpdate file list for target computer $results = Invoke-Command -Computer $target -ScriptBlock ${function:Get-WindowsUpdateFile} -ArgumentList $filter #Download files $destination= "\\172.16.0.1\Shared\Images\WindowsUpdate\WindowsServer2012" foreach($update in $results) { $params = @{ Source = $update.DownloadURL DisplayName = $update.Title Description = $update.DownloadURL Destination = $destination } Start-BitsTransfer @params } ```