From bcbf3ff3206675d8f76874734920515e6d1a3b22 Mon Sep 17 00:00:00 2001 From: i5513 Date: Wed, 8 May 2024 12:07:19 +0200 Subject: [PATCH 1/3] Don't lose UTF8 BOM character --- Public/New-IntuneWin32AppRequirementRuleScript.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Public/New-IntuneWin32AppRequirementRuleScript.ps1 b/Public/New-IntuneWin32AppRequirementRuleScript.ps1 index 6d1581d..60c9283 100644 --- a/Public/New-IntuneWin32AppRequirementRuleScript.ps1 +++ b/Public/New-IntuneWin32AppRequirementRuleScript.ps1 @@ -232,6 +232,9 @@ function New-IntuneWin32AppRequirementRuleScript { # Convert script file contents to base64 string $ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8))) + # Get-Content -Raw will remove BOM UTF8 char, adding the Base64 version of that + # Scripts in powershell 5.1 written in UTF8 need the BOM char + $ScriptContent = "77u/"+ScriptContent switch ($PSCmdlet.ParameterSetName) { "String" { @@ -330,4 +333,4 @@ function New-IntuneWin32AppRequirementRuleScript { # Handle return value with constructed requirement rule for file return $RequirementRuleScript } -} \ No newline at end of file +} From 04e3f84fc6e945af87f9b3e2c5b1f1c27208005f Mon Sep 17 00:00:00 2001 From: i5513 Date: Wed, 8 May 2024 12:16:48 +0200 Subject: [PATCH 2/3] Update New-IntuneWin32AppRequirementRuleScript.ps1 --- Public/New-IntuneWin32AppRequirementRuleScript.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/New-IntuneWin32AppRequirementRuleScript.ps1 b/Public/New-IntuneWin32AppRequirementRuleScript.ps1 index 60c9283..16ee587 100644 --- a/Public/New-IntuneWin32AppRequirementRuleScript.ps1 +++ b/Public/New-IntuneWin32AppRequirementRuleScript.ps1 @@ -234,7 +234,7 @@ function New-IntuneWin32AppRequirementRuleScript { $ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8))) # Get-Content -Raw will remove BOM UTF8 char, adding the Base64 version of that # Scripts in powershell 5.1 written in UTF8 need the BOM char - $ScriptContent = "77u/"+ScriptContent + $ScriptContent = "77u/"+$ScriptContent switch ($PSCmdlet.ParameterSetName) { "String" { From 390dd9da91d0ec60f30038e03617ba3c7d833170 Mon Sep 17 00:00:00 2001 From: i5513 Date: Wed, 8 May 2024 12:49:14 +0200 Subject: [PATCH 3/3] Space betwen operators ... --- Public/New-IntuneWin32AppRequirementRuleScript.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/New-IntuneWin32AppRequirementRuleScript.ps1 b/Public/New-IntuneWin32AppRequirementRuleScript.ps1 index 16ee587..3dd426a 100644 --- a/Public/New-IntuneWin32AppRequirementRuleScript.ps1 +++ b/Public/New-IntuneWin32AppRequirementRuleScript.ps1 @@ -234,7 +234,7 @@ function New-IntuneWin32AppRequirementRuleScript { $ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8))) # Get-Content -Raw will remove BOM UTF8 char, adding the Base64 version of that # Scripts in powershell 5.1 written in UTF8 need the BOM char - $ScriptContent = "77u/"+$ScriptContent + $ScriptContent = "77u/" + $ScriptContent switch ($PSCmdlet.ParameterSetName) { "String" {