Tag: PowerShell

About PowerShell

Windows PowerShell® is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.http://technet.microsoft.com/en-us/library/bb978526.aspx

Starting PowerShell

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.http://technet.microsoft.com/en-us/library/dd315244.aspx

Do one of the following:

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.

Variables

When you write a script, particularly a system administration script, you rarely get to hard-code in all your values ahead of time; instead, you typically need to retrieve information, store that information in a variable or two, and then display the values of those variable.http://technet.microsoft.com/en-us/library/ee692790.aspx

PowerShell is influenced by Unix shells and Perl so variables are prefixed with a $sigil.

Windows PowerShell uses a verb-noun pair for the names of cmdlets and for their derived Microsoft .NET Framework classes. For example, the Get-Command cmdlet provided by Windows PowerShell is used to retrieve all the commands that are registered in Windows PowerShell. The verb part of the name identifies the action that the cmdlet performs. The noun part of the name identifies the entity on which the action is performed.http://msdn.microsoft.com/en-us/library/ms714428(v=vs.85).aspx

Passing Variables to Functions

Previously, $message was accessible because its scope was Global. You can pass variables and values to functions by appending those values to the function call. Also, your function must expect a value. In this example, we pass a string into the function that we declare as $message.