From 8c5693bb521f11920fb8a9d6f65f252db68757cf Mon Sep 17 00:00:00 2001 From: S Thomas <112100724+smtpcx@users.noreply.github.com> Date: Tue, 27 Dec 2022 14:19:31 -0500 Subject: [PATCH] Adjust output to preserve digital signature Added "-NoNewLine" to Out-File cmdlet to avoid extraneous blank line that prevents digitally signed scripts from being exported correctly. --- Get-DeviceHealthScripts.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Get-DeviceHealthScripts.ps1 b/Get-DeviceHealthScripts.ps1 index 9dde7d8..0d14362 100644 --- a/Get-DeviceHealthScripts.ps1 +++ b/Get-DeviceHealthScripts.ps1 @@ -49,14 +49,14 @@ Get-DeviceHealthScripts -FolderPath C:\temp\HealthScripts $healthScriptPath = Join-Path $FolderPath ($script.displayName) New-Item -Path $healthScriptPath -ItemType Directory if (($script.detectionScriptContent).Length -ne 0) { - [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($($script.detectionScriptContent))) | Out-File -Encoding ASCII -FilePath $(Join-Path $healthScriptPath "DetectionScript.ps1") + [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($($script.detectionScriptContent))) | Out-File -NoNewLine -Encoding ASCII -FilePath $(Join-Path $healthScriptPath "DetectionScript.ps1") } if (($script.remediationScriptContent).Length -ne 0) { - [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($($script.remediationScriptContent))) | Out-File -Encoding ASCII -FilePath $(Join-Path $healthScriptPath "RemediationScript.ps1") + [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($($script.remediationScriptContent))) | Out-File -NoNewLine -Encoding ASCII -FilePath $(Join-Path $healthScriptPath "RemediationScript.ps1") } } } Connect-MSGraph | Out-Null -Get-DeviceHealthScripts -FolderPath C:\temp\HealthScripts \ No newline at end of file +Get-DeviceHealthScripts -FolderPath C:\temp\HealthScripts