Skip to content

Instantly share code, notes, and snippets.

@tshm
Last active August 5, 2016 04:38
Show Gist options
  • Save tshm/5c2e3d228874d29af773 to your computer and use it in GitHub Desktop.
Save tshm/5c2e3d228874d29af773 to your computer and use it in GitHub Desktop.
powershell template
@findstr/v "^@f.*&" "%~f0"|powershell -&goto:eof
Write-Output "Hello World"
<#
template
#>
Function Log($obj) {
Write-Output ($obj | Format-Table | Out-String)
Write-Debug -Message "message!!"
}
Function SHA512([String] $str) {
$algorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA512")
$enc = [system.Text.Encoding]::UTF8
$bytes = $algorithm.ComputeHash($enc.GetBytes($str))
return -Join ($bytes | ForEach {"{0:X2}" -f $_})
}
$path = "HKLM:\\SYSTEM\\"
$key = "testKey"
New-ItemProperty -Path $path -Name $key -PropertyType DWORD -Value 1 -Force
net user TestAdmin Abcd123 /add
net localgroup TestAdmin administrators /add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment