diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1 index f7dbb2c7..4f24c971 100644 --- a/scripts/Windows/OS/Setup.ps1 +++ b/scripts/Windows/OS/Setup.ps1 @@ -1,5 +1,8 @@ #!/bin/pwsh +. "$PSScriptRoot/../Scripts/Scripting.ps1"; + function Start-Setup { + . "$PSScriptRoot/../Scripts/Scripting.ps1"; $Global:InformationPreference = "Continue"; $Global:ErrorActionPreference = "Inquire"; $null = $env:WIN_COMPUTER_NAME; @@ -53,14 +56,8 @@ function Start-Setup { Join-Path $env:REMOTE_PROJECT_PATH $relativePath; } - function Get-Injection($value) { - "([System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String('$( - [System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($value)) - )')))" - } - function Get-PathInjection($path) { - "(Join-Path `$env:SystemDrive $(Get-Injection $path))" + "(Join-Path `$env:SystemDrive $(ConvertTo-Injection $path))" } function Get-ScriptPathInjection($path) { diff --git a/scripts/Windows/Scripts/Scripting.ps1 b/scripts/Windows/Scripts/Scripting.ps1 new file mode 100644 index 00000000..e0a9f912 --- /dev/null +++ b/scripts/Windows/Scripts/Scripting.ps1 @@ -0,0 +1,16 @@ +<# + .SYNOPSIS + Converts the specified value into a form to safle inject it into a script. + + .PARAMETER value + The value to convert for injection. +#> +function ConvertTo-Injection { + param( + $Value + ) + + "([System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String('$( + [System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($value)) + )')))" +}