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
#requires -v 3 | |
# remote install: | |
# iex (new-object net.webclient).downloadstring('https://get.scoop.sh') | |
$erroractionpreference='stop' # quit if anything goes wrong | |
# get core functions | |
$core_url = 'https://raw.github.com/lukesampson/scoop/master/lib/core.ps1' | |
echo 'initializing...' | |
iex (new-object net.webclient).downloadstring($core_url) |
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
# to debug sudo problems. | |
# to download: | |
# (new-object net.webclient).downloadfile('https://gist.githubusercontent.com/lukesampson/9130445/raw/sudo_debug.ps1', "$pwd/sudo_debug.ps1") | |
# to test: | |
# ./sudo_debug.ps1 echo hi | |
if(!$args) { "usage: sudo <cmd...>"; exit 1 } | |
function is_admin { | |
write-host "DEBUG: is_admin" | |
$id = [security.principal.windowsidentity]::getcurrent() |
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
{ | |
"version": "0.0.1.z", | |
"url": "https://github.com/jkrehm/pshazz/archive/z.zip", | |
"extract_dir": "pshazz-z", | |
"bin": [ "bin\\pshazz.ps1" ], | |
"installer": { "file": "bin\\install.ps1" } | |
} |
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
param($dir) | |
write-host 'extracting msi...' -nonewline | |
start msiexec -arg '/a', "$dir\vs_setup.msi", '/qn', "TARGETDIR=`"$dir\tmp`"" -wait | |
cp $dir\tmp\* $dir -r -force | |
rm $dir\tmp -r -force | |
rm $dir\vs_setup.msi | |
rm $dir\vs_setup.cab | |
rm $dir\vs_expbsln_x64_enu.cab |
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
# quick exec: | |
# iex (new-object net.webclient).downloadstring('https://gist.github.com/lukesampson/6725722/raw/sudo_diag.ps1') | |
$id = [Security.Principal.WindowsIdentity]::GetCurrent() | |
"current user: $($id.name)" | |
$elevated = ([Security.Principal.WindowsPrincipal]($id)).isinrole("Administrators") | |
"elevated: $elevated" | |
$name = $id.name -replace '^[^\\]*\\', '' | |
$res = gwmi win32_groupuser | ? { $_.partcomponent -match "name=`"$name`"" } |
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
write-host "checking..." | |
# check for apache | |
$apache = scoop which httpd | |
if($lastexitcode -ne 0) { 'Apache isn''t installed. run ''scoop install apache'''; return } | |
# check for php | |
$php = scoop which php | |
if($lastexitcode -ne 0) { 'PHP isn''t installed. run ''scoop install php'''; return } |
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
{ | |
version: "2.0", | |
url: "https://gist.github.com/lukesampson/6446238/raw/hello.ps1", | |
bin: "hello.ps1" | |
} |
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
$name = split-path (whoami) -leaf | |
"Hello, $name!" |
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
# 1. installs a powershell script to ~\appdata\local\scoop\[name]\[name].ps1 | |
# 2. adds a stub to ~\appdata\local\scoop\bin, to avoid path pollution | |
# 3. makes sure ~\appdata\local\scoop\bin is in your path | |
function install($name, $url) { | |
$erroractionpreference = 'stop' | |
# helpers | |
function dl($url,$to) { (new-object system.net.webClient).downloadFile($url,$to) } | |
function env($name,$val) { | |
if($val) { [environment]::setEnvironmentVariable($name,$val,'User') } # set |
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
$usage = "usage: runat (time) (command) | |
e.g. runat 2am shutdown -r -f -c ""restart"""; | |
function esc($s) { [regex]::escape($s) } | |
$t = $args[0] # time | |
if($args.length -gt 1) { # command | |
$c = $args[1..($args.length-1)] | % { if($_ -match '\s') { "`"$_`"" } else { $_ } } |