Skip to content

Commit

Permalink
Merge pull request #44 from JonathanPitre/2312
Browse files Browse the repository at this point in the history
2402.1 On next PR please check the following as well:
The cmdlet 'Get-WindowsAdmxOnline' returns an object of type 'System.Collections.Hashtable' but this type is not declared in the OutputType attribute.

other than that, thanks again!
  • Loading branch information
msfreaks authored Feb 27, 2024
2 parents d5368cb + 46966c7 commit 0133598
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 67 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
* Add logging options (yep, since the beginning)
* Add notification options (yep, also since the beginning)
* Detect user domain automatically (Get code from PSADT)
* Add support for Winget-Autoupdate-Intune ADMX (https://github.com/msfreaks/EvergreenAdmx/issues/35)
* Add support for Winget-Autoupdate-Intune ADMX [#35](https://github.com/msfreaks/EvergreenAdmx/issues/35)
* Add parameter to create Central Policy Store location
* Add parameter to clean old Office ADMX from Central Policy Store location
* Add parameter to clean old Adobe Reader ADMX from Central Policy Store location

## 2402

* Fixed Get-WindowsAdmxOnline version return
* Improved function Get-WindowsAdmxOnline, added default parameters
* Improved function Get-WindowsAdmxDownloadId, added default parameters
* Improved Get-WindowsAdmx speed by switching to MSI extraction [#41](https://github.com/msfreaks/EvergreenAdmx/issues/41)
* Improved Adobe admx downloads with https URLs [#37](https://github.com/msfreaks/EvergreenAdmx/issues/37)
* Added admx for Microsoft Windows 11 (23H2) [#38](https://github.com/msfreaks/EvergreenAdmx/issues/38)
Expand Down
113 changes: 58 additions & 55 deletions EvergreenAdmx.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Requires -RunAsAdministrator

#region init

<#PSScriptInfo
.VERSION 2312.0
Expand Down Expand Up @@ -79,6 +78,7 @@
https://msfreaks.wordpress.com
#>

[CmdletBinding(DefaultParameterSetName = 'Windows11Version')]
param(
[Parameter(Mandatory = $False, ParameterSetName = "Windows10Version", Position = 0)][ValidateSet("1903", "1909", "2004", "20H2", "21H1", "21H2", "22H2")]
Expand Down Expand Up @@ -138,9 +138,8 @@ Write-Verbose "Languages:`t`t`t`t'$($Languages)'"
Write-Verbose "Use product folders:`t'$($UseProductFolders)'"
Write-Verbose "Admx path:`t`t`t`t'$($WorkingDirectory)\admx'"
Write-Verbose "Download path:`t`t`t'$($WorkingDirectory)\downloads'"
Write-Verbose "Included:`t`t`t`t'$($Include -join ',')'"
Write-Verbose "Included:`t`t`t`t'$($Include -join ', ')'"
Write-Verbose "PreferLocalOneDrive:`t'$($PreferLocalOneDrive)'"

#endregion

#region functions
Expand Down Expand Up @@ -886,45 +885,6 @@ function Invoke-Download
}
}

function Get-WindowsAdmxDownloadId
{
<#
.SYNOPSIS
Returns Widnows admx download Id
.PARAMETER WindowsVersion
Specifies Windows version (Example: 23H2)
.PARAMETER WindowsEdition
Specifies Windows edition (Example: 11)
#>

param (
[Parameter()]
[ValidateSet("1903", "1909", "2004", "20H2", "21H1", "21H2", "22H2", "23H2")]
[ValidateNotNullOrEmpty()]
[string]$WindowsVersion,
[ValidateSet("10", "11")]
[ValidateNotNullOrEmpty()]
[int]$WindowsEdition
)

switch ($WindowsEdition)
{
10
{
return (@( @{ "1903" = "58495" }, @{ "1909" = "100591" }, @{ "2004" = "101445" }, @{ "20H2" = "102157" }, @{ "21H1" = "103124" }, @{ "21H2" = "104042" }, @{ "22H2" = "104677" } ).$WindowsVersion)
break
}
11
{
return (@( @{ "21H2" = "103507" }, @{ "22H2" = "104593" }, @{ "23H2" = "105667" } ).$WindowsVersion)
break
}
}
}

function Copy-Admx
{
param (
Expand Down Expand Up @@ -1001,34 +961,73 @@ function Get-MicrosoftOfficeAdmxOnline
#>

$id = "49030"
$url = "https://www.microsoft.com/en-us/download/details.aspx?id=$($id)"
$urldownload = "https://www.microsoft.com/en-us/download/confirmation.aspx?id=$($id)"
$urlVersion = "https://www.microsoft.com/en-us/download/details.aspx?id=$($id)"
$urlDownload = "https://www.microsoft.com/en-us/download/confirmation.aspx?id=$($id)"

try
{

# load page for version scrape
$web = (Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $url).RawContent
$web = (Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urlVersion -MaximumRedirection 0 -UserAgent 'Googlebot/2.1 (+http://www.google.com/bot.html)').RawContent
# grab version
$regEx = '(version\":")((?:\d+\.)+(?:\d+))"'
$version = ($web | Select-String -Pattern $regEx).Matches.Groups[2].Value

# load page for uri scrape
$web = Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urldownload -MaximumRedirection 0
$web = Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urlDownload -MaximumRedirection 0 -UserAgent 'Googlebot/2.1 (+http://www.google.com/bot.html)'
# grab x64 version
$hrefx64 = $web.Links | Where-Object { $_.outerHTML -like "*click here to download manually*" -and $_.href -like "*.exe" -and $_.href -like "*x64*" } | Select-Object -First 1
# grab x86 version
$hrefx86 = $web.Links | Where-Object { $_.outerHTML -like "*click here to download manually*" -and $_.href -like "*.exe" -and $_.href -like "*x86*" } | Select-Object -First 1

# return evergreen object
return @( @{ Version = $Version; URI = $hrefx64.href; Architecture = "x64" }, @{ Version = $Version; URI = $hrefx86.href; Architecture = "x86" })
return @( @{ Version = $version; URI = $hrefx64.href; Architecture = "x64" }, @{ Version = $version; URI = $hrefx86.href; Architecture = "x86" })
}
catch
{
Throw $_
}
}

function Get-WindowsAdmxDownloadId
{
<#
.SYNOPSIS
Returns Windows admx download Id
.PARAMETER WindowsEdition
Specifies Windows edition (Example: 11)
.PARAMETER WindowsVersion
Specifies Windows version (Example: 23H2)
#>

param (
[Parameter(Position = 0, ValueFromPipeline = $true)]
[ValidateSet("10", "11")]
[ValidateNotNullOrEmpty()]
[int]$WindowsEdition = "11",
[Parameter(Position = 1, ValueFromPipeline = $true)]
[ValidateSet("1903", "1909", "2004", "20H2", "21H1", "21H2", "22H2", "23H2")]
[ValidateNotNullOrEmpty()]
[string]$WindowsVersion = "23H2"
)

switch ($WindowsEdition)
{
10
{
return (@( @{ "1903" = "58495" }, @{ "1909" = "100591" }, @{ "2004" = "101445" }, @{ "20H2" = "102157" }, @{ "21H1" = "103124" }, @{ "21H2" = "104042" }, @{ "22H2" = "104677" } ).$WindowsVersion)
break
}
11
{
return (@( @{ "21H2" = "103507" }, @{ "22H2" = "104593" }, @{ "23H2" = "105667" } ).$WindowsVersion)
break
}
}
}

function Get-WindowsAdmxOnline
{
<#
Expand All @@ -1039,26 +1038,30 @@ function Get-WindowsAdmxOnline
Id returned from Get-WindowsAdmxDownloadId
#>

[CmdletBinding()]
param(
[string]$DownloadId
[int]$DownloadId = (Get-WindowsAdmxDownloadId)
)

$urlversion = "https://www.microsoft.com/en-us/download/details.aspx?id=$($DownloadId)"
$urldownload = "https://www.microsoft.com/en-us/download/confirmation.aspx?id=$($DownloadId)"
$urlVersion = "https://www.microsoft.com/en-us/download/details.aspx?id=$($DownloadId)"
$urlDownload = "https://www.microsoft.com/en-us/download/confirmation.aspx?id=$($DownloadId)"

try
{

# load page for version scrape
$web = Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urlversion
$str = ($web.ToString() -split "[`r`n]" | Select-String "Version:").ToString()
$web = Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urlVersion -UserAgent 'Googlebot/2.1 (+http://www.google.com/bot.html)'

# grab version
$Version = "$($DownloadId).$(($str | Select-String -Pattern "(\d+(\.\d+){1,4})" -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }).ToString())"
$regEx = '(version\":")((?:\d+\.)+(?:\d+))"'
$version = ($web | Select-String -Pattern $regEx).Matches.Groups[2].Value

# load page for uri scrape
$web = Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urldownload -MaximumRedirection 0
$web = Invoke-WebRequest -UseDefaultCredentials -UseBasicParsing -Uri $urlDownload -MaximumRedirection 0 -UserAgent 'Googlebot/2.1 (+http://www.google.com/bot.html)'
$href = $web.Links | Where-Object { $_.outerHTML -like "*click here to download manually*" -and $_.href -like "*.msi" } | Select-Object -First 1

# return evergreen object
return @{ Version = $Version; URI = $href.href }
return @{ Version = $version; URI = $href.href }
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 - 2022 Arjan Mensch
Copyright (c) 2020 - 2024 Arjan Mensch

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ This script solves both problems.
* Checks for newer versions of the Admx files that are present and processes the new version if found
* Optionally copies the new Admx files to the Policy Store or Definition folder, or a folder of your choosing

The name I chose for this script is an ode to the Evergreen module (https://github.com/aaronparker/Evergreen) by Aaron Parker (@stealthpuppy).
The name I chose for this script is an ode to the [Evergreen module](https://github.com/aaronparker/Evergreen) by Aaron Parker [@stealthpuppy](https://twitter.com/stealthpuppy).

## How to use

Quick start:
* Download the script to a location of your choosing (for example: C:\Scripts\EvergreenAdmx)
* Run or schedule the script

You can also install the script from the PowerShell Gallery ([EvergreenAdmx][poshgallery-evergreenadmx]):
You can also install the script from the PowerShell Gallery [EvergreenAdmx][poshgallery-evergreenadmx] :
```powershell
Install-Script -Name EvergreenAdmx
```
Expand All @@ -33,6 +33,12 @@ The above execution will keep the central Policy Store up-to-date on a daily bas

A sample .xml file that you can import in Task Scheduler is provided with this script.

`Breaking change starting from 2402.1`

The -WindowsVersion parameter was added back and is now an alias of -Windows11Version

Valid entries are "Custom Policy Store", "Windows 10", "Windows 11", "Microsoft Edge", "Microsoft OneDrive", "Microsoft Office", "FSLogix", "Adobe Acrobat", "Adobe Reader", "BIS-F", "Citrix Workspace App", "Google Chrome", "Microsoft Desktop Optimization Pack", "Mozilla Firefox", "Zoom Desktop Client", "Azure Virtual Desktop".

`Breaking change starting from 2301.1`

Valid entries are "Custom Policy Store", "Windows 10", "Windows 11", "Microsoft Edge", "Microsoft OneDrive", "Microsoft Office", "FSLogix", "Adobe Acrobat", "Adobe Reader", "BIS-F", "Citrix Workspace App", "Google Chrome", "Microsoft Desktop Optimization Pack", "Mozilla Firefox", "Zoom Desktop Client".
Expand Down Expand Up @@ -80,9 +86,8 @@ PARAMETERS
Accept pipeline input? false
Accept wildcard characters? false
-Windows11Version <String>
The Windows 11 version to get the Admx files for. This value will be ignored if 'Windows 10' is
not specified with -Include parameter.
-Windows11Version or WindowsVersion <String>
The Windows 11 version to get the Admx files for.
If omitted, defaults to latest version available.
Required? false
Expand Down Expand Up @@ -182,17 +187,18 @@ PARAMETERS
Also see [Change Log][change-log] for a list of supported products.

Now supports
* Custom Policy Store
* Adobe Acrobat
* Adobe Reader
* Adobe Acrobat (Continuous Track)
* Adobe Reader (Continuous Track)
* Azure Virtual Desktop
* Base Image Script Framework (BIS-F)
* Citrix Workspace App
* Custom Policy Store
* FSLogix
* Google Chrome
* Microsoft Desktop Optimization Pack
* Microsoft Edge (Chromium)
* Microsoft Office
* Microsoft OneDrive (installed or Evergreen)
* Microsoft OneDrive (local installation or Evergreen)
* Microsoft Windows 10 (1903/1909/2004/20H2/21H1/21H2/22H2)
* Microsoft Windows 11 (21H2/22H2/23H2)
* Mozilla Firefox
Expand All @@ -206,7 +212,7 @@ For instance, the Windows 10 and Windows 11 Admx files are in an msi file, the O
If you are going to use the script to download Windows 10 or Windows 11 Admx files, you will need to remove any installs of the Windows 10 or Windows 11 Admx msi, or the script will fail.
So this is what the script does for these packages: installing the package, copying the Admx files, uninstalling the package.

Thank you Jonathan Pitre (@PitreJonathan) for keeping me sharp, providing fixes and improvements!
Thank you [Jonathan Pitre](https://github.com/JonathanPitre) for keeping me sharp, providing fixes and improvements!

[github-release-badge]: https://img.shields.io/github/v/release/msfreaks/EvergreenAdmx.svg?style=flat-square
[github-release]: https://github.com/msfreaks/EvergreenAdmx/releases/latest
Expand Down

0 comments on commit 0133598

Please sign in to comment.