2/11/11

PowerShell 2 Aliases

Get-Alias cmdlet

Alias    Definition  
%        ForEach-Object
?        Where-Object
ac       Add-Content
asnp     Add-PSSnapIn
cat      Get-Content
cd       Set-Location
chdir    Set-Location
clc      Clear-Content
clear    Clear-Host
clhy     Clear-History
cli      Clear-Item
clp      Clear-ItemProperty
cls      Clear-Host
clv      Clear-Variable
compare  Compare-Object
copy     Copy-Item
cp       Copy-Item
cpi      Copy-Item
cpp      Copy-ItemProperty
cvpa     Convert-Path
dbp      Disable-PSBreakpoint
del      Remove-Item
diff     Compare-Object
dir      Get-ChildItem
ebp      Enable-PSBreakpoint
echo     Write-Output
epal     Export-Alias
epcsv    Export-Csv
epsn     Export-PSSession
erase    Remove-Item
etsn     Enter-PSSession
exsn     Exit-PSSession
fc       Format-Custom
fl       Format-List
foreach  ForEach-Object
ft       Format-Table
fw       Format-Wide
gal      Get-Alias
gbp      Get-PSBreakpoint
gc       Get-Content
gci      Get-ChildItem
gcm      Get-Command
gcs      Get-PSCallStack
gdr      Get-PSDrive
ghy      Get-History
gi       Get-Item
gjb      Get-Job
gl       Get-Location
gm       Get-Member
gmo      Get-Module
gp       Get-ItemProperty
gps      Get-Process
group    Group-Object
gsn      Get-PSSession
gsnp     Get-PSSnapIn
gsv      Get-Service
gu       Get-Unique
gv       Get-Variable
gwmi     Get-WmiObject
h        Get-History
history  Get-History
icm      Invoke-Command
iex      Invoke-Expression
ihy      Invoke-History
ii       Invoke-Item
ipal     Import-Alias
ipcsv    Import-Csv
ipmo     Import-Module
ipsn     Import-PSSession
ise      powershell_ise.exe
iwmi     Invoke-WMIMethod
kill     Stop-Process
lp       Out-Printer
ls       Get-ChildItem
man      help
md       mkdir
measure  Measure-Object
mi       Move-Item
mount    New-PSDrive
move     Move-Item
mp       Move-ItemProperty
mv       Move-Item
nal      New-Alias
ndr      New-PSDrive
ni       New-Item
nmo      New-Module
nsn      New-PSSession
nv       New-Variable
ogv      Out-GridView
oh       Out-Host
popd     Pop-Location
ps       Get-Process
pushd    Push-Location
pwd      Get-Location
r        Invoke-History
rbp      Remove-PSBreakpoint
rcjb     Receive-Job
rd       Remove-Item
rdr      Remove-PSDrive
ren      Rename-Item
ri       Remove-Item
rjb      Remove-Job
rm       Remove-Item
rmdir    Remove-Item
rmo      Remove-Module
rni      Rename-Item
rnp      Rename-ItemProperty
rp       Remove-ItemProperty
rsn      Remove-PSSession
rsnp     Remove-PSSnapin
rv       Remove-Variable
rvpa     Resolve-Path
rwmi     Remove-WMIObject
sajb     Start-Job
sal      Set-Alias
saps     Start-Process
sasv     Start-Service
sbp      Set-PSBreakpoint
sc       Set-Content
select   Select-Object
set      Set-Variable
si       Set-Item
sl       Set-Location
sleep    Start-Sleep
sort     Sort-Object
sp       Set-ItemProperty
spjb     Stop-Job
spps     Stop-Process
spsv     Stop-Service
start    Start-Process
sv       Set-Variable
swmi     Set-WMIInstance
tee      Tee-Object
type     Get-Content
where    Where-Object
wjb      Wait-Job
write    Write-Output


2-Column Custom Format Example using Get-Alias
Dynamically format a 2-column output with N-spaces padding, based on first column width
1. get data
2. calc column 1 max length
3. calc column 2 start index
4. loop & print
$data = get-alias
$numberOfSpaces = 2
$col1MaxLength = ($data | %{$_.name.length} | measure -max).maximum  #7
$col2StartIndex = ($col1MaxLength + $numberOfSpaces)  #9

#format: 0=alias, 1=calc padding, 2=def
$data | %{"{0}{1}{2}" -f $_.name, (" " * (($col2StartIndex - $_.name.length))), $_.definition}
Debug
AliasInfo Class
#get-alias returns AliasInfo array
$data[0].gettype()  #AliasInfo : System.Management.Automation.CommandInfo

#using the measure-object cmdlet to get alias name length stats
$data | %{$_.name.length} | measure -min -max -ave -sum
count   : 137
average : 3.25
sum     : 445   #na
maximum : 7     #for this example we only need MAX
minimum : 1

2/1/11

HTTP Response Status Codes

1xx Informational
100 Continue
101 Switching Protocols
102 Processing (WebDAV)

2xx Success
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status (WebDAV)

3xx Redirection
300 Multiple Choices
301 Moved Permanently (permanent redirect)
302 Found (temporary redirect)
303 See Other
304 Not Modified
305 Use Proxy
306 Switch Proxy
307 Temporary Redirect

4xx Client Errors
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
418 I'm a teapot
422 Unprocessable Entity (WebDAV)
423 Locked (WebDAV)
424 Failed Dependency (WebDAV)
425 Unordered Collection
444 No Response
426 Upgrade Required
449 Retry With
450 Blocked by Windows Parental Controls
499 Client Closed Request

5xx Server Errors
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported
506 Variant Also Negotiates
507 Insufficient Storage (WebDAV)
509 Bandwidth Limit Exceeded (Apache)
510 Not Extended

JavaScript encodeURI and encodeURIComponent

ASCII Char Comparisons
#    CH  EU     EUC  NOTES
32       %20    %20  space char
96   `   %60    %60
33   !   !      !
64   @   @      %40  x
35   #   #      %23  x
36   $   $      %24  x
37   %   %25    %25
94   ^   %5E    %5E
38   &   &      %26  x
42   *   *      *
40   (   (      (
41   )   )      )
45   -   -      -
61   =   =      %3D  x
91   [   %5B    %5B
93   ]   %5D    %5D
92   \   %5C    %5C
59   ;   ;      %3B  x
39   '   '      '
44   ,   ,      %2C  x
46   .   .      .
47   /   /      %2F  x
126  ~   ~      ~
95   _   _      _
43   +   +      %2B  x
123  {   %7B    %7B
125  }   %7D    %7D
124  |   %7C    %7C
58   :   :      %3A  x
34   "   %22    %22
60   <   %3C    %3C
62   >   %3E    %3E
63   ?   ?      %3F  x

LEGEND
#   ascii code
CH  char
EU  encodeURI
EUC encodeURIComponent
x   diffs

List Chars using jQuery map()
//escape char: \
chars = " `!@#$%^&*()-=[]\\;',./~_+{}|:\"<>?"
jQuery.map(chars.split(""),
  function(c) {
    console.log(c.charCodeAt(0) + " " + c + "  " + encodeURI(c) + "  " + encodeURIComponent(c));
  })

NATO Phonetic Alphabet

AAlpha•–
BBravo–•••
CCharlie–•–•
DDelta–••
EEcho
FFoxtrot••–•
GGolf––•
HHotel••••
IIndia••
JJuliet•–––
KKilo–•–
LLima•–••
MMike––
NNovember–•
OOscar–––
PPapa•––•
QQuebec––•–
RRomeo•–•
SSierra•••
TTango
UUniform••–
VVictor•••–
WWhiskey•––
XX–ray–••–
YYankee–•––
ZZulu––••