Gandip's Blog

My Blogs

PowerShell (Basics)

Powershell is a administrative engine which is interactive command shell. Its is more of scripting language. It is combination of objects from .NET,COM, and WMI frameworks. Windows PowerShell can be extened with:

  • Providers
  • Cmdlets
  • Scripts,functions,aliases

Cmdlets pronounced Command Lets is light weight used in Windows PowerShell enviroment.

PowerShell Extension:

Administration of Microsoft Product like Exchange 2007 Service Pack 1,SQL 2008 R2, Windows Server 2008 now can be done using PowerShell. An example EMS (Exchange Management Shell) now capable of doing all administration in Exchange Server which GUI may not be able to do so. It is just a extension of PowerShell. PSSnapIn is used.

PowerShell Providers:

Using Providers for PowerShell now one can hover around Registry, File System, Certiuficate Store using PowerShell “drives” PSdrive. PSdrive depends open PowerShell providers.

Using PSdrive:

Get-PSdrive to check the list of all current Powershell drives

image

New-PSdrive to Create new PowerShell Drive

Accessing Registry

Using push-location with appropriate location of registry

push-location HKCU:

this will change the current path to registry (HKEY_Current_User). Like hover in registry you can use get-childitem to look around and cd to change the path.

Objects::

Objects have interfaces that act like handles to get information into and out of the object. In other words, an object can be more than just a set of data. In addition to interfaces and methods, an object can have properties or attributes that describe it.

Following is an example of changing a user interface with a property assignment:

$Host.UI.RawUI.ForegroundColor = "Blue"

Use get-member to get the properties and method of any object.

e.g.

get-date|get-member

Dot operator

Use (.) operator to access member of an object.

To pass value of one command into other use parenthesis () for this purpose.

e.g.

(get-date).day

2

(get-date).dayofweek

Monday

To be Continued…

Posted: 05-03-2010 8:18 PM by gandip | with no comments
Filed under: