2. Command line interpreter
Unix shell
Apple script
MS-DOS
Windows Script Host
Windows PowerShell
Administrative tasks
Routine tasks
Maintenance tasks
Shell scripting
3. 1. Install Microsoft .NET Framework 2.0
2. Install Microsoft .NET Framework 3.5.1.
Required for Windows PowerShell Integrated Scripting
Environment (ISE) and Out-GridView.
3. Install WinRM 2.0 CTP3. (Windows Remote Shell)
This is required if you want to take advantage of the remoting and
back- ground jobs features.
4. Install Windows PowerShell 2.
Starting point (ps2)
5. Set Execution Policy
Customise Console
Profile editing
Profile using
Permission and Profiling
6. Cmdlets
Windows
PowerShell
(Cmdlet)
Windows PowerShell
(Alias)
cmd.exe /
COMMAND.COM
(MS-DOS, Windows,
OS/2, etc.)
Description
Get-Location gl, pwd cd Display the current directory/present working directory.
Set-Location sl, cd, chdir cd, chdir Change the current directory
Clear-Host cls, clear cls Clear the screen
Copy-Item cpi, copy, cp copy Copy one or several files / a whole directory tree
Get-Help help, man help Help on commands
Remove-Item ri, del, erase, rmdir, rd, rm del, erase, rmdir, rd Delete a file / a directory
Rename-Item rni, ren ren, rename Rename a file / a directory
Move-Item mi, move, mv move Move a file / a directory to a new location
Get-ChildItem gci, dir, ls dir List all files / directories in the (current) directory
Write-Output echo, write echo Print strings, variables etc. to standard output
Pop-Location popd popd
Change the current directory to the directory most recently
pushed onto the stack
Push-Location pushd pushd Push the current directory onto the stack
Set-Variable sv, set set Set the value of a variable / create a variable
7. Boolean: True or false condition.
Byte: An 8-bit unsigned whole number from 0 to 255, such as 32.
Char: A 16-bit unsigned whole number from 0 to 65,535. For example, 1,026.
Date: A calendar date, such as January 1, 2009.
Decimal: A 128-bit decimal value, such as 3.14159265.
Double: A double-precision 64-bit floating point number. In effect, this is another kind of
decimal value but has a narrower range of values than a decimal.
Integer: A 32-bit signed whole number from –2,147,483,648 to 2,147,483,647, such as 152 or –
1839.
Long: A 64-bit signed whole number. This is like an integer but holds far more values, such as
9,233,372,036,854,775,807.
Object: Any kind of object.
Short: A 16-bit unsigned whole number. This is like an integer but holds far fewer values. It
can only hold values from –32,768 to 32,767.
Single: A single-precision 32-bit floating point number. This is like a double but holds far
fewer values, such as 20.3654.
String: A grouping of characters that most people just call text.
Data types
9. $Error: An array of error objects representing the most recent errors.
$Host: Current host application for Windows PowerShell.
$Profile: Stores the full path to the Windows PowerShell user profile for
the default shell.
$PID: Contains the process identifier of the Windows PowerShell
process.
$PSUICulture: Stores the name of the UI culture currently in use.
$NULL: Contains NULL or empty value.
$False: Contains FALSE.
$True: Contains TRUE.
Automatic variables
13. Operator Meaning
-eq Equal
-ne Not equal
-ine Not equal; not case sensitive (new in Windows PowerShell 2)
-lt Less than
-le Less than or equal
-gt Greater than
-ge Greater than or equal
Operators
14. if statement
switch statement
for loop
foreach loop
while loop
do while loop
do until loop
Control flow statements
21. Message box
Installed drivers info
Path shrink
Convert to PDF
Send email
Hello Anna
Text to audio recording
Cool stuff
22. Not allowing scripts to execute
Improperly using commas to separate parameters when
calling a function
Not defining functions before using them
Forgetting that pipelines pass objects and not just strings
Not casting variables as a string
Making incorrect comparisons
Expending the pipeline to far
Not taking variable scope in account
Debugging without the debugger
Forgetting to use available .NET classes
Common Mistakes
23. Windows PowerShell™ 2 For Dummies® by Steve Seguis
http://powershell.com/cs/
http://en.wikipedia.org/wiki/Windows_PowerShell
http://sandunangelo.blogspot.com/2010/02/introduction-to-
powershell-scripting.html
References