Resources
Sites about PowerShell:
- http://www.microsoft.com/powershell - this is where you can download PowerShell and also access a script repository
- PowerShell Team Blog
- TechNet PowerShell ScriptCentre
- The PowerShell Guy Blog
- powershell.com - MVP website with script repository, tips, community forums, etc.
Getting started with PowerShell:
- Scripting Centre's series of 5 webcasts providing a thorough introduction to PowerShell
- PowerShell 101, lesson 1 on Windows IT Pro
- PowerGUI
- Windows IT Pro talks about the 10 best features of PowerGUI, a script editor that includes a built-in debugger
- PowerShell Plus - another IDE
- Setting up a PowerShell environment
- Blog Series - PowerShell Not Your Father’s Command Line
Specifics:
- PowerShell Profiles - allow functions and variables to be persistent
More Resources:
- Download PowerShell for Windows Vista
- Download PowerShell for Windows XP
- FAQ for installing PowerShell on Windows Vista and "Longhorn" Server
Using PowerShell
A cmdlet is a single-feature command that manipulates an object. They use a verb-noun syntax, eg. Get-Service and Start-Service.
Objects have properties which can be read and written to, eg. the service name and it's startup state, and methods, eg. start and stop.
Make use of tab completion. Pipe output to other cmdlets. Important: you are not pipelining the text output, you are actually passing the objects. eg. get-service returns a lot less information than get-service | format-list
Use the Get-Help cmdlet to learn what is possible. eg. Get-Help Get-Service. For detailed help type Get-Help Get-Service -detailed or Get-Help Get-Service -full.
Assign a variable like so: $DNS=get-service DNS
This creates an object reference. Eg you can return the status of the DNS service by typing: $DNS.status
Use the pipeline variable as a placeholder for the current object within the current pipeline. eg. get-service | where-object { $_.status -eq "Running" }
Cmdlets can have aliases. Type alias for a list of them. eg. Where-Object also has an alias of Where, so the command can be shortened to get-service | where ( $_.status -eq "Running" }
Get cmdlets
The Get-* cmdlets pull data from places. Eg. Get-ChildItem will list folder contents, like dir or ls. Pipe it through Format-Table or Format-List to change the way the output is displayed. Check 'help Get-Table' to see options.
PS> Get-ChildItem C:\ d* | Format-Table name -HideTableName
Desktop
Documents
Downloads
Working with Active Directory
There is not yet an Active Directory Provider for PowerShell, it should become a lot easier when this is created. I know the CTP of PowerShell 2.0 is available for download but haven't yet found whether this is an included feature.
For now, this article might be interesting. I think someone from the community may have created it for themself?
