PowerShell

PowerShell

Resources

Sites about PowerShell:

 

Getting started with PowerShell:

Specifics:

More Resources:

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?