Wednesday, February 19, 2014

Getting started with PowerShell


The Purpose of PowerShell
PowerShell allow you to improve the windows management and helps to improve automation.
PowerShell manages real-time commands with large-scale integration.

How to install PowerShell
PowerShell V3 is comes with Windows Management Framework 3.0
PowerShell V3 is compatible with
  • Windows 8
  • Windows Server 2012
  • Windows 7 SP1
  • Windows Server 2008 R2 SP1
  • Windows Server 2008 SP2

Download Windows Management Framework 3.0
Prerequisite: Full .NET Framework 4.0
Windows XP and Windows Server 2003 can run PowerShell V2
TIP: Always run PowerShell as Administrator.

PowerShell Security Goals
By default PowerShell is secured.
It prevents mistakes by unintentional admins and users.
By clicking on scripts it will not execute scripts, so mistakes can be avoided.
.ps1 extension can be used with notepad or any text editor. You can also use PowerShell ISE. We will talk about this later.
We must have to type full path of file to access or execute file. Shorten paths are restricted to prevent mistakes.

Execution Policy
In PowerShell, there are some execution policies defined for security levels.
By default execution policy is Restricted, which does not execute the script.
Command to know your current execution policy:
        GET-ExecutionPolicy
Command to set execution policy:
        SET-ExecutionPolicy <TYPE>
TYPE can be like
  • Restricted
  • Unrestricted
  • AllSigned
  • Remotesigned
  • Bypass
  • Undefined

Windows PowerShell ISE
The Windows PowerShell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In Windows PowerShell ISE, you can run commands and write, test, and debug scripts in a single Windows-based graphic user interface with multiline editing, tab completion, syntax coloring, selective execution, context-sensitive help, and support for right-to-left languages. You can use menu items and keyboard shortcuts to perform many of the same tasks that you would perform in the Windows PowerShell console.  For example, when you debug a script in the Windows PowerShell ISE, to set a line breakpoint in a script, right-click the line of code, and then click Toggle Breakpoint.

Feature of PowerShell ISE
  • Multiline editing: To insert a blank line under the current line in the Command pane, press SHIFT+ENTER.
  • Selective execution: To run part of a script, select the text you want to run, and then click the Run Script button. Or, press F5.
  • Context-sensitive help: Type Invoke-Item, and then press F1. The Help file opens to the Help topic for the Invoke-Item cmdlet.

To start Windows PowerShell ISE
  • Click Start, point to All Programs, point to Windows PowerShell V2, and then click Windows PowerShell ISE.
  • In the Windows PowerShell console Cmd.exe, or in the Run box, type, powershell_ise.exe



0 comments:

Post a Comment

Freemarket.com Marketplace