Skip to content

Instantly share code, notes, and snippets.

@reschex
Last active November 21, 2023 13:48
Show Gist options
  • Save reschex/b2e3972c664e466fc2925962390c71cd to your computer and use it in GitHub Desktop.
Save reschex/b2e3972c664e466fc2925962390c71cd to your computer and use it in GitHub Desktop.
powershell base64 function
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