Last active
November 21, 2023 13:48
-
-
Save reschex/b2e3972c664e466fc2925962390c71cd to your computer and use it in GitHub Desktop.
powershell base64 function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-Alias grep Select-String -force | |
function which { | |
param ( | |
[Parameter(Mandatory = $true)] | |
[string]$value | |
) | |
return (Get-Command $value).Source | |
} | |
function base64 { | |
param ( | |
[Parameter(Mandatory = $false)] | |
[switch]$d, | |
[Parameter(Mandatory = $false)] | |
[string]$value, | |
[Parameter(ValueFromPipeline=$true)] | |
[string[]]$in | |
) | |
$value = $in ? $in : $value | |
if (Test-Path -Path $value -PathType Leaf) { | |
$value = Get-Content $value | |
} | |
switch ($d) { | |
$true { | |
return [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($value)) | |
} | |
Default { | |
return [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($value)) | |
} | |
} | |
} | |
function whoami { | |
Write-Host "> User :" (C:/Windows/System32/whoami) | |
Write-Host "> IP :" (Invoke-WebRequest ifconfig.me/ip) | |
Write-Host "> Azure:" (az account show | ConvertFrom-Json).Name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment