From 64c4b488ebf504e6846396cbcccc0e145459ca86 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sat, 22 Oct 2022 22:30:44 +0300 Subject: [PATCH] Update CI/CD scripts --- Scripts/Dependencies.ps1 | 52 +++++++++++++++----------------- Scripts/Windows_10.ps1 | 20 ++++++------ Scripts/Windows_10_LTSC_2019.ps1 | 26 ++++++++++------ Scripts/Windows_10_LTSC_2021.ps1 | 20 ++++++------ Scripts/Windows_10_PS_7.ps1 | 20 ++++++------ Scripts/Windows_11.ps1 | 20 ++++++------ Scripts/Windows_11_PS_7.ps1 | 20 ++++++------ 7 files changed, 90 insertions(+), 88 deletions(-) diff --git a/Scripts/Dependencies.ps1 b/Scripts/Dependencies.ps1 index 5963cc1c..dee97482 100644 --- a/Scripts/Dependencies.ps1 +++ b/Scripts/Dependencies.ps1 @@ -1,42 +1,38 @@ Write-Verbose -Message Dependencies -Verbose -# Download PolicyFileEditor -# https://github.com/dlwyatt/PolicyFileEditor +# Download LGPO +# https://techcommunity.microsoft.com/t5/microsoft-security-baselines/lgpo-exe-local-group-policy-object-utility-v1-0/ba-p/701045 $Parameters = @{ - Uri = "https://api.github.com/repos/dlwyatt/PolicyFileEditor/releases/latest" - UseBasicParsing = $true -} -$LatestPolicyFileEditorVersion = (Invoke-RestMethod @Parameters).tag_name -$Parameters = @{ - Uri = "https://github.com/dlwyatt/PolicyFileEditor/archive/refs/tags/$LatestPolicyFileEditorVersion.zip" - OutFile = "Scripts\$LatestPolicyFileEditorVersion.zip" - UseBasicParsing = $true - Verbose = $true + Uri = "https://download.microsoft.com/download/8/5/C/85C25433-A1B0-4FFA-9429-7E023E7DA8D8/LGPO.zip" + OutFile = "Scripts\LGPO.zip" + UseBasicParsing = $true + Verbose = $true } Invoke-WebRequest @Parameters + # Expand zip archive $Parameters = @{ - Path = "Scripts\$LatestPolicyFileEditorVersion.zip" - DestinationPath = "Scripts" - Force = $true - Verbose = $true + Path = "Scripts\LGPO.zip" + DestinationPath = "Scripts" + Force = $true + Verbose = $true } Expand-Archive @Parameters -$Path = @( - "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion\DscResources", - "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion\en-US", - "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion\build.psake.ps1", - "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion\LICENSE", - "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion\PolicyFileEditor.Tests.ps1", - "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion\README.md" -) -Remove-Item -Path $Path -Recurse -Force -Rename-Item -Path "Scripts\PolicyFileEditor-$LatestPolicyFileEditorVersion" -NewName "PolicyFileEditor" -Force + +$Parameters = @{ + Path = "Scripts\LGPO_30\LGPO.exe" + Destination = Scripts + Force = $true +} +Move-Item @Parameters + +Remove-Item -Path "Scripts\LGPO_30", "Scripts\LGPO.zip" -Recurse -Force + # Download Microsoft.Windows.SDK.NET.dll & WinRT.Runtime.dll $Parameters = @{ - Uri = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref" - OutFile = "Scripts\microsoft.windows.sdk.net.ref.zip" - UseBasicParsing = $true + Uri = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref" + OutFile = "Scripts\microsoft.windows.sdk.net.ref.zip" + UseBasicParsing = $true } Invoke-RestMethod @Parameters # Extract Microsoft.Windows.SDK.NET.dll & WinRT.Runtime.dll from archive diff --git a/Scripts/Windows_10.ps1 b/Scripts/Windows_10.ps1 index 4267ea3b..d716f75a 100644 --- a/Scripts/Windows_10.ps1 +++ b/Scripts/Windows_10.ps1 @@ -1,6 +1,6 @@ # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1 @@ -9,24 +9,24 @@ Write-Verbose -Message "Sophia.Script.for.Windows.10.v$LatestRelease.zip" -Verbo New-Item -Path "Sophia_Script_for_Windows_10_v$LatestRelease\bin" -ItemType Directory -Force $Parameters = @{ - Path = @("Scripts\PolicyFileEditor") - Destination = "Sophia_Script_for_Windows_10_v$LatestRelease\bin" - Recurse = $true - Force = $true + Path = @("Scripts\LGPO.exe") + Destination = "Sophia_Script_for_Windows_10_v$LatestRelease\bin" + Recurse = $true + Force = $true } Copy-Item @Parameters Get-ChildItem -Path "src\Sophia_Script_for_Windows_10" -Force | Copy-Item -Destination "Sophia_Script_for_Windows_10_v$LatestRelease" -Recurse -Force $Parameters = @{ - Path = "Sophia_Script_for_Windows_10_v$LatestRelease" - DestinationPath = "Sophia.Script.for.Windows.10.v$LatestRelease.zip" - CompressionLevel = "Fastest" - Force = $true + Path = "Sophia_Script_for_Windows_10_v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.10.v$LatestRelease.zip" + CompressionLevel = "Fastest" + Force = $true } Compress-Archive @Parameters # Calculate hash Get-Item -Path "Sophia.Script.for.Windows.10.v$LatestRelease.zip" -Force | ForEach-Object -Process { - "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding utf8 -Force diff --git a/Scripts/Windows_10_LTSC_2019.ps1 b/Scripts/Windows_10_LTSC_2019.ps1 index 4125c158..d6f20ad5 100644 --- a/Scripts/Windows_10_LTSC_2019.ps1 +++ b/Scripts/Windows_10_LTSC_2019.ps1 @@ -1,26 +1,32 @@ # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2019 + Write-Verbose -Message "Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" -Verbose + New-Item -Path "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\bin" -ItemType Directory -Force + $Parameters = @{ - Path = @("Scripts\PolicyFileEditor") - Destination = "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\bin" - Recurse = $true - Force = $true + Path = @("Scripts\LGPO.exe") + Destination = "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease\bin" + Recurse = $true + Force = $true } Copy-Item @Parameters + Get-ChildItem -Path "src\Sophia_Script_for_Windows_10_LTSC_2019" -Force | Copy-Item -Destination "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease" -Recurse -Force + $Parameters = @{ - Path = "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease" - DestinationPath = "Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" - CompressionLevel = "Fastest" - Force = $true + Path = "Sophia_Script_for_Windows_10_LTSC_2019_v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" + CompressionLevel = "Fastest" + Force = $true } Compress-Archive @Parameters + # Calculate hash Get-Item -Path "Sophia.Script.for.Windows.10.LTSC.2019.v$LatestRelease.zip" -Force | ForEach-Object -Process { - "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding utf8 -Force diff --git a/Scripts/Windows_10_LTSC_2021.ps1 b/Scripts/Windows_10_LTSC_2021.ps1 index 4189fb5c..6bcb4c9e 100644 --- a/Scripts/Windows_10_LTSC_2021.ps1 +++ b/Scripts/Windows_10_LTSC_2021.ps1 @@ -1,6 +1,6 @@ # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021 @@ -9,24 +9,24 @@ Write-Verbose -Message "Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.z New-Item -Path "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\bin" -ItemType Directory -Force $Parameters = @{ - Path = @("Scripts\PolicyFileEditor") - Destination = "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\bin" - Recurse = $true - Force = $true + Path = @("Scripts\LGPO.exe") + Destination = "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease\bin" + Recurse = $true + Force = $true } Copy-Item @Parameters Get-ChildItem -Path "src\Sophia_Script_for_Windows_10_LTSC_2021" -Force | Copy-Item -Destination "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease" -Recurse -Force $Parameters = @{ - Path = "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease" - DestinationPath = "Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" - CompressionLevel = "Fastest" - Force = $true + Path = "Sophia_Script_for_Windows_10_LTSC_2021_v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" + CompressionLevel = "Fastest" + Force = $true } Compress-Archive @Parameters # Calculate hash Get-Item -Path "Sophia.Script.for.Windows.10.LTSC.2021.v$LatestRelease.zip" -Force | ForEach-Object -Process { - "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding utf8 -Force diff --git a/Scripts/Windows_10_PS_7.ps1 b/Scripts/Windows_10_PS_7.ps1 index 69d8d00f..b1f1901a 100644 --- a/Scripts/Windows_10_PS_7.ps1 +++ b/Scripts/Windows_10_PS_7.ps1 @@ -1,6 +1,6 @@ # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7 @@ -9,24 +9,24 @@ Write-Verbose -Message "Sophia.Script.for.Windows.10.PowerShell.7.v$LatestReleas New-Item -Path "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\bin" -ItemType Directory -Force $Parameters = @{ - Path = @("Scripts\PolicyFileEditor", "Scripts\WinRT.Runtime.dll", "Scripts\Microsoft.Windows.SDK.NET.dll") - Destination = "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\bin" - Recurse = $true - Force = $true + Path = @("Scripts\LGPO.exe", "Scripts\WinRT.Runtime.dll", "Scripts\Microsoft.Windows.SDK.NET.dll") + Destination = "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease\bin" + Recurse = $true + Force = $true } Copy-Item @Parameters Get-ChildItem -Path "src\Sophia_Script_for_Windows_10_PowerShell_7" -Force | Copy-Item -Destination "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease" -Recurse -Force $Parameters = @{ - Path = "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease" - DestinationPath = "Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" - CompressionLevel = "Fastest" - Force = $true + Path = "Sophia_Script_for_Windows_10_PowerShell_7_v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" + CompressionLevel = "Fastest" + Force = $true } Compress-Archive @Parameters # Calculate hash Get-Item -Path "Sophia.Script.for.Windows.10.PowerShell.7.v$LatestRelease.zip" -Force | ForEach-Object -Process { - "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding utf8 -Force diff --git a/Scripts/Windows_11.ps1 b/Scripts/Windows_11.ps1 index b2f50163..79445115 100644 --- a/Scripts/Windows_11.ps1 +++ b/Scripts/Windows_11.ps1 @@ -1,6 +1,6 @@ # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1 @@ -9,24 +9,24 @@ Write-Verbose -Message "Sophia.Script.for.Windows.11.v$LatestRelease.zip" -Verbo New-Item -Path "Sophia_Script_for_Windows_11_v$LatestRelease\bin" -ItemType Directory -Force $Parameters = @{ - Path = @("Scripts\PolicyFileEditor") - Destination = "Sophia_Script_for_Windows_11_v$LatestRelease\bin" - Recurse = $true - Force = $true + Path = @("Scripts\LGPO.exe") + Destination = "Sophia_Script_for_Windows_11_v$LatestRelease\bin" + Recurse = $true + Force = $true } Copy-Item @Parameters Get-ChildItem -Path "src\Sophia_Script_for_Windows_11" -Force | Copy-Item -Destination "Sophia_Script_for_Windows_11_v$LatestRelease" -Recurse -Force $Parameters = @{ - Path = "Sophia_Script_for_Windows_11_v$LatestRelease" - DestinationPath = "Sophia.Script.for.Windows.11.v$LatestRelease.zip" - CompressionLevel = "Fastest" - Force = $true + Path = "Sophia_Script_for_Windows_11_v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.11.v$LatestRelease.zip" + CompressionLevel = "Fastest" + Force = $true } Compress-Archive @Parameters # Calculate hash Get-Item -Path "Sophia.Script.for.Windows.11.v$LatestRelease.zip" -Force | ForEach-Object -Process { - "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding utf8 -Force diff --git a/Scripts/Windows_11_PS_7.ps1 b/Scripts/Windows_11_PS_7.ps1 index 34eeaa10..353f9fcf 100644 --- a/Scripts/Windows_11_PS_7.ps1 +++ b/Scripts/Windows_11_PS_7.ps1 @@ -1,6 +1,6 @@ # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_7 @@ -9,24 +9,24 @@ Write-Verbose -Message "Sophia.Script.for.Windows.11.PowerShell.7.v$LatestReleas New-Item -Path "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\bin" -ItemType Directory -Force $Parameters = @{ - Path = @("Scripts\PolicyFileEditor", "Scripts\WinRT.Runtime.dll", "Scripts\Microsoft.Windows.SDK.NET.dll") - Destination = "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\bin" - Recurse = $true - Force = $true + Path = @("Scripts\LGPO.exe", "Scripts\WinRT.Runtime.dll", "Scripts\Microsoft.Windows.SDK.NET.dll") + Destination = "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease\bin" + Recurse = $true + Force = $true } Copy-Item @Parameters Get-ChildItem -Path "src\Sophia_Script_for_Windows_11_PowerShell_7" -Force | Copy-Item -Destination "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease" -Recurse -Force $Parameters = @{ - Path = "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease" - DestinationPath = "Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" - CompressionLevel = "Fastest" - Force = $true + Path = "Sophia_Script_for_Windows_11_PowerShell_7_v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" + CompressionLevel = "Fastest" + Force = $true } Compress-Archive @Parameters # Calculate hash Get-Item -Path "Sophia.Script.for.Windows.11.PowerShell.7.v$LatestRelease.zip" -Force | ForEach-Object -Process { - "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding utf8 -Force