Skip to content

Instantly share code, notes, and snippets.

@craysiii
Created May 2, 2020 08:30
Show Gist options
  • Save craysiii/0c603320f83d94001d0d07c9a079b409 to your computer and use it in GitHub Desktop.
Save craysiii/0c603320f83d94001d0d07c9a079b409 to your computer and use it in GitHub Desktop.
Powershell Snippets for VS Code
{
"Create Directory": {
"prefix": "cray-Create-Directory",
"body": [
"[System.IO.Directory]::CreateDirectory(\"$0\")"
],
"description": "Create a directory unless it already exists"
},
"Download File": {
"prefix": "cray-Download-File",
"body": [
"(New-Object Net.WebClient).DownloadFile($1, $2)"
],
"description": "Download a file"
},
"Get Applications": {
"prefix": "cray-Get-Applications",
"body": [
"\\$64bit = if ([System.IntPtr]::Size -eq 8) { \\$true } else { \\$false }",
"\\$RegKeys = @('HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\')",
"if (\\$true -eq \\$64bit) { \\$RegKeys += 'HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\'}",
"\\$Apps = \\$RegKeys | Get-ChildItem | Get-ItemProperty | Where-Object { \\$_.DisplayName -eq '$0' }"
],
"description": "Get a list of applications installed according to DisplayName"
},
"Silent Uninstall": {
"prefix": "cray-Silent-Uninstall",
"body": [
"Start-Process -FilePath \"MsiExec.exe\" -ArgumentList \"/X ${Installer} /quiet /qn /norestart\" -Wait"
],
"description": "Silently uninstall an application via MsiExec"
},
"Silent Install": {
"prefix": "cray-Silent-Install",
"body": [
"Start-Process -FilePath \"MsiExec.exe\" -ArgumentList \"/i ${Installer} /quiet /qn /norestart /log ${Log}.log$0\" -Wait"
],
"description": "Silently install an application via MsiExec"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment