Skip to content

Instantly share code, notes, and snippets.

@gravcat
Created September 22, 2017 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravcat/fb55eae8fb3b9b15d6239985c79e6c02 to your computer and use it in GitHub Desktop.
Save gravcat/fb55eae8fb3b9b15d6239985c79e6c02 to your computer and use it in GitHub Desktop.
function Create-Shortcut {
param (
[String]
$target,
[String]
$shortcutFile,
[Switch]
$admin,
[String]
$startIn
)
$WScriptShell = New-Object -ComObject WScript.Shell -Verbose
$Shortcut = $WScriptShell.CreateShortcut("$shortcutFile.lnk")
$Shortcut.TargetPath = $target
if ($startIn) { $Shortcut.WorkingDirectory = "$startIn"; }
$Shortcut.Save()
if ($admin) {
# modify byte to set admin launch flag (hack!)
# https://stackoverflow.com/a/29002207/5175396
$bytes = [System.IO.File]::ReadAllBytes("$shortcutFile.lnk")
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes("$shortcutFile.lnk", $bytes)
}
}
# create shortcuts for interesting folders, cmd, ps, ps ise
Create-Shortcut -target "C:\Orchestrate" -shortcutFile "C:\Users\Public\Desktop\Orchestrate"
Create-Shortcut -target "C:\Windows\System32\cmd.exe" -shortcutFile "C:\Users\Public\Desktop\CMD-User" -startIn "C:\Orchestrate"
Create-Shortcut -target "C:\Windows\System32\cmd.exe" -shortcutFile "C:\Users\Public\Desktop\CMD-Admin" -admin -startIn "C:\Orchestrate"
Create-Shortcut -target "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -shortcutFile "C:\Users\Public\Desktop\PS-User" -startIn "C:\Orchestrate"
Create-Shortcut -target "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -shortcutFile "C:\Users\Public\Desktop\PS-Admin" -admin -startIn "C:\Orchestrate"
Create-Shortcut -target "C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe" -shortcutFile "C:\Users\Public\Desktop\PS ISE-User" -startIn "C:\Orchestrate"
Create-Shortcut -target "C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe" -shortcutFile "C:\Users\Public\Desktop\PS ISE-Admin" -admin -startIn "C:\Orchestrate"
# make life easier for someone that has to log into the machine
<# notepad++
google chrome
cyberduck - multi-tool for connecting to storage services like ftp, s3, azure, way more. helpful if we need to manually ship anything around
7zip
python
azcopy - azure cli utility for interacting with azure storage resources. might be handy for quick stuff
fiddler - if anyone needs to hop on the machine to mess with any web apps
#>
choco install -y notepadplusplus googlechrome cyberduck.install 7zip.install python2 azcopy fiddler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment