Skip to content

Commit

Permalink
Update Harden-Windows-Security.ps1
Browse files Browse the repository at this point in the history
Adjusted the parameters for the AppControl function
  • Loading branch information
HotCakeX committed Oct 26, 2024
1 parent 53aab8d commit 6d9c77a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions AppControl Manager/Pages/Update.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ await Task.Run(() =>

// Run the PowerShell script to check for updates and save the output code
psOutput = PowerShellExecutor.ExecuteScript($"""
$VerbosePreference = 'Continue';
(irm 'https://raw.githubusercontent.com/HotCakeX/Harden-Windows-Security/main/Harden-Windows-Security.ps1')+'AppControl -CheckForUpdate {currentAppVersion}'|iex
""", true);
});
Expand Down
23 changes: 11 additions & 12 deletions Harden-Windows-Security.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ Function AppControl {
#>
[CmdletBinding()]
param (
[ValidatePattern('_(\d+\.\d+\.\d+\.\d+)_(x64|arm64)\.msix$')][ValidateScript({ Test-Path -LiteralPath $_ -PathType Leaf })]
[Parameter(Mandatory = $false)][System.String]$MSIXPath,
[ValidateScript({ Test-Path -LiteralPath $_ -PathType Leaf })][Parameter(Mandatory = $False)][System.String]$SignTool,
[Parameter(Mandatory = $False)][System.String]$SignTool,
[Parameter(Mandatory = $False)][System.Version]$CheckForUpdate
)
$ErrorActionPreference = 'Stop'
Expand All @@ -199,6 +198,13 @@ Function AppControl {
return
}

Write-Verbose -Message 'Detecting the CPU Arch'
switch ($Env:PROCESSOR_ARCHITECTURE) {
'AMD64' { [System.String]$CPUArch = 'x64'; break }
'ARM64' { [System.String]$CPUArch = 'arm64'; break }
default { Throw [System.PlatformNotSupportedException] 'Only AMD64 and ARM64 architectures are supported.' }
}

# Used to generate a SecureString, adding the class only if it hasn't already been added to the session - Better version of the random number generator would require PowerShell core/.NET
if (!([System.Management.Automation.PSTypeName]'SecureStringGenerator').Type) {
Add-Type -TypeDefinition @'
Expand Down Expand Up @@ -321,15 +327,8 @@ public static class SecureStringGenerator
Write-Verbose -Message 'Extracting the nupkg'
Expand-Archive -Path "$WorkingDir\*.nupkg" -DestinationPath $WorkingDir -Force

Write-Verbose -Message 'Detecting the CPU Arch'
switch ($Env:PROCESSOR_ARCHITECTURE) {
'AMD64' { [System.String]$CPUArch = 'x64'; break }
'ARM64' { [System.String]$CPUArch = 'arm64'; break }
default { Throw [System.PlatformNotSupportedException] 'Only AMD64 and ARM64 architectures are supported.' }
}

Write-Verbose -Message 'Finding the Signtool.exe path in the extracted directory'
$SignTool = "$WorkingDir\bin\*\$CPUArch\signtool.exe"
$SignTool = (Get-Item -Path "$WorkingDir\bin\*\$CPUArch\signtool.exe").FullName
}

# Download the MSIX package if user did not provide the path to it
Expand All @@ -347,7 +346,7 @@ public static class SecureStringGenerator
$InstallingAppArchitecture = $RegexMatch.Groups['Architecture'].Value
}
else {
throw 'Could not get the version of the installing app'
throw 'Could not get the version of the installing app from the MSIX download URL.'
}
}
else {
Expand All @@ -359,7 +358,7 @@ public static class SecureStringGenerator
$InstallingAppArchitecture = $RegexMatch.Groups['Architecture'].Value
}
else {
throw 'Could not get the version of the installing app'
throw 'Could not get the version of the installing app from the -MSIX parameter value that you provided.'
}
}

Expand Down

0 comments on commit 6d9c77a

Please sign in to comment.