Getting Started with Windows PowerShell


Firstly you have to Install PowerShell

As the initial step you need to make sure PowerShell is running in your system. Keep in mind that in this lab scenario Window 8.1 operating system is used. Since windows 8.1 comes with pre-installed PowerShell you can skip this step. For earlier versions such as Windows Vista you need to download and install PowerShell manually.

Download Link:

To Check the PowerShell version



get-host |select-object version 

get-host version



Set PowerShell’s Execution Policy

  • Restricted – PowerShell won’t run any scripts. This is PowerShell’s default execution policy.
  • AllSigned – PowerShell will only run scripts that are signed with a digital signature. If you run a script signed by a publisher PowerShell hasn’t seen before, PowerShell will ask whether you trust the script’s publisher.
  • RemoteSigned – PowerShell won’t run scripts downloaded from the Internet unless they have a digital signature, but scripts not downloaded from the Internet will run without prompting. If a script has a digital signature, PowerShell will prompt you before it runs a script from a publisher it hasn’t seen before.
  • Unrestricted – PowerShell ignores digital signatures but will still prompt you before running a script downloaded from the Internet.
  • Bypass – Everything runs without a warning. Be careful with this one.
  • Undefined – No policy is defined in the current scope. This is used to allow fall-back to policies defined in lower scopes (more details below) or to the OS defaults.

Check the current policy


01 get policy

Change the policy into RemoteSigned

Set-ExecutionPolicy RemoteSigned

02 set policy

Run Your First PowerShell script

Create a script file with following content. Name the file as MyScript.ps1

Write-Host "Hello, world"

Save the MyScript.ps1 file into following folder


03 capture

Run Following commands at PowerShell

PS C:\> Set-Location C:\Scripts

PS C:\Scripts> .\MyScript.ps1

04 run script

Alternatively you can use cmd.exe to run the scripts

In this case following script is used to get the information.

computer hostname = w

$computers = "w"

Get-WmiObject -Class win32_bios -cn $computers |

Format-table __Server, Manufacturer, Version -AutoSize

05 cmd prompt

You can use PowerShell scripts against Multiple Computers

In this scenario Windows Server 2012 R2 server domain environment is used to run the scripts.

Save following script in MyScript.ps1 file.

$computers = Get-Content -Path C:\Scripts\Computers.txt

Get-WmiObject -Class win32_bios -cn $computers -EA silentlyContinue |

Format-table __Server, Manufacturer, Version –AutoSize

Watermark Multiple Computers MyScript script file

And Make sure the computers list in the network is saved as a text file in Computers.txt.


Computers list Text File.png

The path of the text file should be


Run the PowerShell script

PS C:\> Set-Location C:\Scripts

PS C:\Scripts> .\MyScript.ps1

Watermark Multiple Computers powershell



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s