About80Ninjas icon

ConvertTo-EncodedScript

About80Ninjas | PRO | 01/08/16 01:44:16 PM UTC | 0 ⭐ | 390 👁️ | Never ⏰ | []
PowerShell |

460 B

|

None

|

0 👍

/

0 👎

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
    } 
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎