Skip to content
This repository has been archived by the owner on Feb 28, 2021. It is now read-only.

v3 #40

Merged
merged 20 commits into from
Jun 6, 2019
Merged

v3 #40

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions LatestUpdate/LatestUpdate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"SearchStrings" : {
"ServicingStack" : "^Servicing stack update.*",
"CumulativeUpdate" : ".*Cumulative Update.*",
"AdobeFlash" : ".*Update for Adobe Flash Player.*",
"MonthlyRollup" : "(?!Preview of Monthly Rollup)(\\(Monthly Rollup.*\\))",
"NetFramework" : "Cumulative Update for \\.NET Framework",
"NetFrameworkWindows10" : "Windows 10|Windows Server 2016|Windows Server 2019|Windows Server",
"NetFrameworkWindows8" : "Windows 8.1|Server 2012 R2",
"NetFrameworkWindows7" : "Windows 7|Server 2008 R2"
},
"Matches" : {
"DownloadUrl" : "(http[s]?\\://download\\.windowsupdate\\.com\\/[^\\'\\\"\"]*)",
"DownloadDescription" : "<a[^>]*>([^<]+)<\\/a>",
"Windows10Version" : "([12][056789][01][379])",
"Architecture" : "(x86|x64|ARM64)"
},
"CatalogUris" : {
"Search" : "https://www.catalog.update.microsoft.com/Search.aspx?q=",
"Download" : "https://www.catalog.update.microsoft.com/DownloadDialog.aspx"
},
"UpdateFeeds" : {
"Windows10" : "https://support.microsoft.com/app/content/api/content/feeds/sap/en-us/6ae59d69-36fc-8e4d-23dd-631d98bf74a9/atom",
"Windows8" : "https://support.microsoft.com/app/content/api/content/feeds/sap/en-us/b905caa1-d413-c90c-bed3-20aead901092/atom",
"Windows7" : "https://support.microsoft.com/app/content/api/content/feeds/sap/en-us/f825ca23-c7d1-aab8-4513-64980e1c3007/atom",
"NetFramework" : "https://support.microsoft.com/app/content/api/content/feeds/sap/en-us/df2c02f6-9610-d46d-2d76-fa570bd8c86a/atom"
},
"VersionTable" : {
"Windows10" : {
"1803" : "17134",
"1809" : "17763",
"1703" : "15063",
"1709" : "16299",
"1607" : "14393",
"1903" : "18362"
}
},
"Languages" : {
"Default" : "en-US"
},
"Architecture" : {
"x64" : "x64-based",
"x86" : "x86-based",
"ARM" : "ARM64-based",
"All" : "x86|x64|ARM64"
},
"Preferences" : {
"ErrorAction" : "SilentlyContinue"
},
"ContentType" : {
"html" : "text/html; charset=utf-8",
"atom" : "application/atom+xml; charset=utf-8"
}
}
168 changes: 83 additions & 85 deletions LatestUpdate/LatestUpdate.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,134 +8,132 @@

@{

# Script module or binary module file associated with this manifest.
RootModule = 'LatestUpdate.psm1'
# Script module or binary module file associated with this manifest.
RootModule = 'LatestUpdate.psm1'

# Version number of this module.
ModuleVersion = '2.4.99'
# Version number of this module.
ModuleVersion = '3.0.99'

# Supported PSEditions
# CompatiblePSEditions = @()
# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '1a3f9720-247a-4a25-8120-a164b35856ef'
# ID used to uniquely identify this module
GUID = '1a3f9720-247a-4a25-8120-a164b35856ef'

# Author of this module
Author = 'Aaron Parker'
# Author of this module
Author = 'Aaron Parker'

# Company or vendor of this module
CompanyName = 'stealthpuppy'
# Company or vendor of this module
CompanyName = 'stealthpuppy'

# Copyright statement for this module
Copyright = '(c) 2018-2019 stealthpuppy. All rights reserved.'
# Copyright statement for this module
Copyright = '(c) 2019 stealthpuppy. All rights reserved.'

# Description of the functionality provided by this module
Description = 'A module for retrieving the latest Windows 10 / Windows Server 2016, 2019, Semi Annual Channel Cumulative Updates and Servicing Stack Update, the Monthly Rollups for 8.1 / 7 (and Windows Server 2012 R2, 2008 R2) and the latest Adobe Flash Player updates from the Microsoft Update History page. In addition, the module provides functions for downloading the update file/s locally and importing into a Microsoft Deployment Toolkit deployment share.
# Description of the functionality provided by this module
Description = 'A module for retrieving the latest Windows 10 / Windows Server 2016, 2019, Semi Annual Channel Cumulative Updates, Servicing Stack Updates, .NET Framework Cumulative Updates, the Monthly Rollups for 8.1 / 7 (and Windows Server 2012 R2, 2008 R2) and the latest Adobe Flash Player updates from the Microsoft Update History page. In addition, the module provides a function for downloading the update files locally.

This module assists IT Pros in speeding Windows operating system deployments with offline patching in MDT for reference images or PC deployments, or direct application of updates to a WIM.
This module assists IT Pros in speeding Windows operating system deployments with tracking of Windows updates, offline patching in MDT for reference images or PC deployments, or direct application of updates to a WIM.

Get-LatestUpdate, Get-LatestServicingStack, Get-LatestFlash and Save-LatestUpdate support PowerShell Core; however, Import-LatestUpdate requires the Microsoft Deployment Toolkit, so requires Windows PowerShell until Microsoft updates the MDT PowerShell module to support PowerShell Core.'
PowerShell Core is full suppported.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Get-LatestFlash', 'Get-LatestNetFramework',
'Get-LatestServicingStack', 'Get-LatestUpdate', 'Import-LatestUpdate',
'Save-LatestUpdate')
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Get-LatestCumulativeUpdate', 'Get-LatestServicingStackUpdate', 'Get-LatestAdobeFlashUpdate', 'Save-LatestUpdate', 'Get-LatestMonthlyRollup', 'Get-LatestNetFrameworkUpdate')

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
# VariablesToExport = @()
# Variables to export from this module
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'Get-LatestUpdate', 'Get-LatestFlash', 'Get-LatestServicingStack'

# DSC resources to export from this module
# DscResourcesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()
# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()
# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

#RepositorySourceLocation of this module
RepositorySourceLocation = 'https://github.com/aaronparker/LatestUpdate/'
#RepositorySourceLocation of this module
RepositorySourceLocation = 'https://github.com/aaronparker/LatestUpdate/'

PSData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Windows10','WindowsServer2019','WindowsServer2016','CumulativeUpdate','AdobeFlash','Adobe','Flash','LatestUpdate','MDT','MicrosoftDeploymentToolkit','MonthlyUpdate','ServicingStack'
# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Windows10', 'WindowsServer2019', 'WindowsServer2016', 'CumulativeUpdate', 'AdobeFlash', 'Adobe', 'Flash', 'LatestUpdate', 'MDT', 'MicrosoftDeploymentToolkit', 'MonthlyUpdate', 'ServicingStack'

# A URL to the license for this module.
LicenseUri = 'https://github.com/aaronparker/LatestUpdate/blob/master/LICENSE'
# A URL to the license for this module.
LicenseUri = 'https://github.com/aaronparker/LatestUpdate/blob/master/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/aaronparker/LatestUpdate/'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/aaronparker/LatestUpdate/'

# A URL to an icon representing this module.
IconUri = 'https://raw.githubusercontent.com/aaronparker/LatestUpdate/master/img/download.png'
# A URL to an icon representing this module.
IconUri = 'https://raw.githubusercontent.com/aaronparker/LatestUpdate/master/img/download.png'

# ReleaseNotes of this module
ReleaseNotes = 'https://docs.stealthpuppy.com/docs/latestupdate/change-log'
# ReleaseNotes of this module
ReleaseNotes = 'https://docs.stealthpuppy.com/docs/latestupdate/change-log'

# Prerelease string of this module
# Prerelease = ''
# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()
# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable
} # End of PSData hashtable

} # End of PrivateData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

13 changes: 8 additions & 5 deletions LatestUpdate/LatestUpdate.psm1
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Get public and private function definition files
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue )
$publicRoot = Join-Path -Path $PSScriptRoot -ChildPath "Public"
$privateRoot = Join-Path -Path $PSScriptRoot -ChildPath "Private"
$public = @( Get-ChildItem -Path (Join-Path $publicRoot "*.ps1") -ErrorAction SilentlyContinue )
$private = @( Get-ChildItem -Path (Join-Path $privateRoot "*.ps1") -ErrorAction SilentlyContinue )

# Dot source the files
ForEach ($import in @($Public + $Private)) {
ForEach ($import in @($public + $private)) {
Try {
. $import.fullname
}
Catch {
Write-Error -Message "Failed to import function $($import.fullname): $_"
Write-Warning -Message "Failed to import function $($import.fullname)."
Throw $_.Exception.Message
}
}

# Export the Public modules
Export-ModuleMember -Function $Public.Basename
Export-ModuleMember -Function $public.Basename -Alias *
36 changes: 36 additions & 0 deletions LatestUpdate/Private/Add-Property.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Function Add-Property {
<#
.SYNOPSIS
Adds a property to a PSObject by querying another property
#>
[OutputType([System.Management.Automation.PSObject])]
[CmdletBinding(SupportsShouldProcess = $False)]
Param (
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSObject] $InputObject,

[Parameter(Mandatory = $True, Position = 1, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[System.String] $Property,

[Parameter(Mandatory = $True, Position = 2, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[System.String] $NewPropertyName,

[Parameter(Mandatory = $True, Position = 3, ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[System.String] $MatchPattern
)

ForEach ($object in $InputObject) {
$value = $object | Select-Object -ExpandProperty $Property | `
Select-String -AllMatches -Pattern $MatchPattern | `
ForEach-Object { $_.Matches.Value }
If ($value.Count -ge 2) {
$value = $value | Select-Object -Last 1
}
$object | Add-Member -NotePropertyName $NewPropertyName -NotePropertyValue $value
Write-Output -InputObject $object
}
}
52 changes: 52 additions & 0 deletions LatestUpdate/Private/ConvertTo-Hashtable.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Function ConvertTo-Hashtable {
<#
.SYNOPSIS
Converts a PSCustomObject into a hashtable for Windows PowerShell

.NOTES
Author: Adam Bertram
Link: https://4sysops.com/archives/convert-json-to-a-powershell-hash-table
#>
[CmdletBinding()]
[OutputType('hashtable')]
Param (
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline)]
$InputObject
)

Process {
## Return null if the input is null. This can happen when calling the function
## recursively and a property is null
If ($Null -eq $InputObject) {
Return $Null
}

## Check if the input is an array or collection. If so, we also need to convert
## those types into hash tables as well. This function will convert all child
## objects into hash tables (if applicable)
If ($InputObject -is [System.Collections.IEnumerable] -and $InputObject -isnot [string]) {
$collection = @(
ForEach ($object in $InputObject) {
ConvertTo-Hashtable -InputObject $object
}
)

## Return the array but don't enumerate it because the object may be pretty complex
Write-Output -NoEnumerate -InputObject $collection
}
ElseIf ($InputObject -is [psobject]) {
## If the object has properties that need enumeration
## Convert it to its own hash table and return it
$hash = @{ }
ForEach ($property in $InputObject.PSObject.Properties) {
$hash[$property.Name] = ConvertTo-Hashtable -InputObject $property.Value
}
$hash
}
Else {
## If the object isn't an array, collection, or other object, it's already a hash table
## So just return it.
$InputObject
}
}
}
Loading