Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ConvertTo-EncodedScript
- {
- param(
- $Path,
- [Switch]$Open
- )
- $Code = Get-Content -Path $Path -Raw
- $Bytes = [System.Text.Encoding]::Unicode.GetBytes($Code)
- $Base64 = [Convert]::ToBase64String($Bytes)
- $NewPath = [System.IO.Path]::ChangeExtension($Path, '.pse1')
- $Base64 | Set-Content -Path $NewPath
- if ($Open.IsPresent)
- {
- notepad.exe $NewPath
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement