| | | | | | |

  Terminal Services
 
 

Scripting with Windows PowerShell

What is PowerShell?

PowerShell is Microsoft's new command shell and scripting language. It provides task based scripting using cmdlets.

Installation Requirements

PowerShell requires the release-to-manufacturing version of .NET Framework 2.0 to be installed first.

Supported Operating Systems are Windows Server 2003; Windows Server 2003 R2 (32-Bit x86); Windows Server 2003 Service Pack 1; Windows Vista; Windows XP; Windows XP Service Pack 1; Windows XP Service Pack 2.

What Can PowerShell do:

There are are many PowerShell cmdlets, from retrieving WMI Objects to manipulating the Windows Eventlog. This powerful scripting language can integrate into WSH and VBS scripts. Below is a list of the many cmdlets you can run. Example: After downloading and installing both .Net Framework 2.0 and PowerShell, launch powershell.exe and you will get a command prompt that looks something like the DOS command shell.

You can restart services to manipulating files and directories etc....

Simple example of what you can do with PowerShell is restart a service using the cmdlet "restart-service".

From the Powershell command prompt you can type restart-service spooler , you can also restart multiple services as well.

Downloading and Installing Windows PowerShell RC1



Cmdlet Name

Short Description

Add-Content

Adds to the content(s) of the specified item(s).

Add-History

Adds entries to the session history.

Add-Member

Adds a user defined custom member to an Object.

Add-PSSnapin

Adds one or more PSSnapIn(s) to the current Ps console.

Clear-Content

The clear-content Cmdlet removes the content from an item or file while leaving the file intact.

Clear-Item

Sets the item(s) at the specified location to the "clear" value specified by the provider.

Clear-ItemProperty

Removes the property value from a property.

Clear-Variable

Removes the value from a variable.

Compare-Object

Compares the properties of objects.

ConvertFrom-SecureString

Export a securestring to a safe, persistable format

Convert-Path

Converts the path of the item given from an Ps path to a provider path.

ConvertTo-Html

Converts the input into an HTML table

ConvertTo-SecureString

Create a securestring from a normal string created by export-securestring

Copy-Item

Calls a provider to copy an item from one location to another within a namespace.

Copy-ItemProperty

Copies a property between locations or namespaces.

Export-Alias

Exports an alias list to a file.

Export-Clixml

Produces a clixml representation of a PowerShell object or objects.

Export-Console

Export the changes made to the current console. This action overwrites any existing console file.

Export-Csv

Forms CSV strings from input.

ForEach-Object

Applies script blocks to each object in the pipeline

Format-Custom

Formats output display as defined in additions to the formatter file.

Format-List

Formats objects as a list of their properties displayed vertically.

Format-Table

Formats the output as a table

Format-Wide

Formats objects as a table of their properties.

Get-Acl

Gets the access control list (ACL) associated with a file or object.

Get-Alias

Returns alias names for Cmdlets

Get-AuthenticodeSignature

Gets the signature object associated with a file.

Get-ChildItem

Retrieves the child items of the specified location(s) in a drive.

Get-Command

Retrieves basic information about a command.

Get-Content

The get-content command gets the content from the item at the specified location.

Get-Credential

Gets a credential object based on a password

Get-Culture

Gets the culture information

Get-Date

Gets current date and time

Get-EventLog

Gets eventlog data for the machine.

Get-ExecutionPolicy

Gets the effective execution policy for the current shell.

Get-Help

Opens the help files

Get-History

Gets a listing of the session history

Get-Host

Gets host information

Get-Item

Returns an object that represents an item in a namespace.

Get-ItemProperty

Retrieves the properties of an object.

Get-Location

Displays the current location.

Get-Member

This Cmdlet enumerates the properties, methods, typeinfo and property sets of the objects given to it.

Get-PfxCertificate

Gets the pfx certificate information.

Get-Process

Gets a list of processes on a machine.

Get-PSDrive

Gets the drive information (DriveInfo) for the specified Ps Drive

Get-PSProvider

Gets information for the specified provider.

Get-PSSnapin

Lists registered PSSnapIns.

Get-Service

Gets a list of services.

Get-TraceSource

Lists properties for given trace sources.

Get-UICulture

Gets the uiculture information

Get-Unique

Gets the unique items in a sorted list

Get-Variable

Gets a PowerShell variable

Get-WmiObject

Produce a WMI Object or the list of WMI classes available on the system.

Group-Object

Groups the objects that contain the same value for a common property.

Import-Alias

Imports an alias list from a file.

Import-Clixml

Imports a clixml file and rebuilds the PowerShell object.

Import-Csv

Takes values from a CSV list and sends objects down the pipeline.

Invoke-Expression

Executes a string as an expression

Invoke-History

Invokes a previously executed command.

Invoke-Item

Invokes an executable or opens a file

Join-Path

Combines path elements into a single path.

Measure-Command

Tracks running time for script blocks and Cmdlets

Measure-Object

Measures various aspects of objects or their properties.

Move-Item

Moves an item from one location to another

Move-ItemProperty

Moves a property from one location to another.

New-Alias

Creates a new Cmdlet-alias pairing

New-Item

Creates a new item in a namespace

New-ItemProperty

Sets a new property of an item at a location

New-Object

Creates a new .Net object

New-PSDrive

Installs a new drive on the machine.

New-Service

Creates a new service

New-TimeSpan

Creates a timespan object

New-Variable

Creates a new variable.

Out-Default

The default controller of output.

Out-File

Sends command output to a file.

Out-Host

Sends the pipelined output to the host

Out-Null

Sends ouput to a null

Out-Printer

Sends the output to a printer.

Out-String

Sends output to the pipleline as strings.

Pop-Location

Changes the current working location to the location specified by the last entry pushed onto the stack.

Push-Location

Pushes a location to the stack

Read-Host

Read a line of input from the host console.

Remove-Item

Calls a provider to remove an item.

Remove-ItemProperty

Removes a property and its value from the location.

Remove-PSDrive

Removes a drive from its location.

Remove-PSSnapin

Remove PSSnapIn(s) from the current console process.

Remove-Variable

Removes a variable and its value

Rename-Item

Changes the name of an existing item.

Rename-ItemProperty

Renames a property at its location.

Resolve-Path

Resolves the wildcards in a path

Restart-Service

Restarts a stopped service

Resume-Service

Resumes a suspended service

Select-Object

Selects objects based on parameters set in the Cmdlet command string.

Select-String

This cmdlet lets you search through strings or files for patterns.

Set-Acl

Set a resource's Access Control List Properties

Set-Alias

Maps an alias to a Cmdlet

Set-AuthenticodeSignature

Place an authenticode signature in an Ps script or other file.

Set-Content

The set-content command sets the content in the item at the specified location.

Set-Date

Sets the system time on the host system.

Set-ExecutionPolicy

Set the execution policy for the current shell.

Set-Item

The set-item command sets the value of a pathname within a provider to the specified value.

Set-ItemProperty

Sets a property at the specified location to a specified value.

Set-Location

Sets the current working location to a specified location.

Set-PSDebug

Turn Ps script debugging features on and off, and set trace level.

Set-Service

Makes and sets changes to the properties of a service.

Set-TraceSource

Sets or removes the specified options and trace listeners from the specified trace source instance(s).

Set-Variable

Sets data in a variable and creates a variable if one with the requested name does not exist.

Sort-Object

Sorts the input objects by property values.

Split-Path

Given an Ps path(s) it streams a string with the qualifier, parent path or leaf item.

Start-Service

Starts a stopped service.

Start-Sleep

Suspend shell, script, or runspace activity for the specified period of time.

Start-Transcript

Starts a transcript of a command shell session.

Stop-Process

Stops a running process

Stop-Service

Stops a running service

Stop-Transcript

Stops the transcription process

Suspend-Service

Suspends a running service.

Tee-Object

Sends input objects to two places.

Test-Path

Returns true if the path exists, otherwise it returns false.

Trace-Command

Enables tracing of the specified trace source instance(s) for the duration of the expression or command.

Update-FormatData

Updates and appends format data files.

Update-TypeData

Updates the types.ps1xml file in the Microsoft Shell

Where-Object

This Cmdlet filters the input from the pipeline allowing operation on only certain objects.

Write-Debug

Writes a debug message to the host display

Write-Error

Writes an error object and sends it to the pipeline.

Write-Host

Displays objects through the user feedback mechanism.

Write-Output

Writes an object to the pipeline

Write-Progress

Sends a progress record to the host.

Write-Verbose

Writes a string to the host's verbose display

Write-Warning

Write a warning message


Quick Links

s.chiara@comcast.net