Tutorial by Examples

Windows PowerShell is included with the Windows Management Framework. Installation and Setup are not required on modern versions of Windows. Updates to PowerShell can be accomplished by installing a newer version of the Windows Management Framework. Other Platforms "Beta" version of P...
For security reasons, PowerShell is set up by default to only allow signed scripts to execute. Executing the following command will allow you to run unsigned scripts (you must run PowerShell as Administrator to do this). Set-ExecutionPolicy RemoteSigned Another way to run PowerShell scripts is t...
In PowerShell, there are many ways to achieve the same result. This can be illustrated nicely with the simple & familiar Hello World example: Using Write-Host: Write-Host "Hello World" Using Write-Output: Write-Output 'Hello world' It's worth noting that although Write-Outp...
One of the first questions people have when they begin to use PowerShell for scripting is how to manipulate the output from a cmdlet to perform another action. The pipeline symbol | is used at the end of a cmdlet to take the data it exports and feed it to the next cmdlet. A simple example is using...
To comment on power scripts by prepending the line using the # (hash) symbol # This is a comment in powershell Get-ChildItem You can also have multi-line comments using <# and #> at the beginning and end of the comment respectively. <# This is a multi-line comment #> Get-Chil...
Static .Net library methods can be called from PowerShell by encapsulating the full class name in third bracket and then calling the method using :: #calling Path.GetFileName() C:\> [System.IO.Path]::GetFileName('C:\Windows\explorer.exe') explorer.exe Static methods can be called from the c...
The New-Object cmdlet is used to create an object. # Create a DateTime object and stores the object in variable "$var" $var = New-Object System.DateTime # calling constructor with parameters $sr = New-Object System.IO.StreamReader -ArgumentList "file path" In many instan...

Page 1 of 1