Learning PowerShell – Lesson One

Share:
PowerShell

PowerShell Lesson One

By: Steven Aiello

Note! Much of this content is taken from various Microsoft websites, which means it will be very dry and boring to read; however, there’s no one better to tell you what PowerShell is then its creator.

Teach Your Self PowerShell – Introduction to PowerShell

What is PowerShell?

http://msdn.microsoft.com/en-us/library/windows/desktop/aa973757(v=vs.85).aspx

Windows PowerShell is a new Windows command-line shell designed especially for system administrators. The Windows PowerShell includes an interactive prompt and a scripting environment that can be used independently or in combination.

 

Unlike most shells, which accept and return text, Windows PowerShell is built on top of the .NET Framework common language runtime (CLR) and the .NET Framework, and accepts and returns .NET Framework objects. This fundamental change in the environment brings entirely new tools and methods to the management and configuration of Windows.

Windows PowerShell introduces the concept of a cmdlet (pronounced “command-let”), a simple, single-function command-line tool built into the shell. You can use each cmdlet separately, but their power is realized when you use these simple tools in combination to perform complex tasks. Windows PowerShell includes more than one hundred basic core cmdlets, and you can write your own cmdlets and share them with other users.

 

Like many shells, Windows PowerShell gives you access to the file system on the computer. In addition, Windows PowerShell providers enable you to access other data stores, such as the registry and the digital signature certificate stores, as easily as you access the file system.

 

This Getting Started guide provides an introduction to Windows PowerShell: the language, the cmdlets, the providers, and the use of objects.

How can PowerShell be used?

PowerShell can be used by system administrators to replace point and click actions when administering servers. In many cases it is not feasible to manually log into dozens or hundreds of servers to execute commands from the GUI. In this case PowerShell is a great alternative for Windows administrators because PowerShell scripts can be executed against many servers at one time.

In addition to executing simple commands PowerShell has logical operators which can be used to create logic in a script. PowerShell can take action on a system based on the conditions of that system. For example: if you have a mission critical database you could in theory write a PowerShell script to monitor the state of your MS SQL service. “If” the service is in a stopped state the PowerShell script could attempt to restart the service. If the script attempts to restart the service and that restart attempt fails the script could then use the SMTP protocol to e-mail the administrator as to the status of that service.

What are the system requirements for PowerShell?

http://technet.microsoft.com/en-us/library/hh847769.aspx

Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0

This topic lists the system requirements for Windows PowerShell 3.0 and for special features, such as Windows PowerShell Integrated Scripting Environment (ISE), CIM commands and workflows.

Windows® 8 and Windows Server® 2012 include all required programs. This topic is designed for users of earlier versions of Windows.

Operating System Requirements

Windows PowerShell 3.0 runs on the following versions of Windows.

Windows 8

Windows Server 2012

Windows® 7 with Service Pack 1

Windows Server® 2008 R2 with Service Pack 1

Windows Server 2008 with Service Pack 2

Microsoft .NET Framework Requirements

Windows PowerShell 3.0 requires the full installation of Microsoft .NET Framework 4.0. Windows 8 and Windows Server 2012 include Microsoft .NET Framework 4.5, which fulfills this requirement.

To install Microsoft .NET Framework 4.5, see “.NET 4.5 Developer Preview” on the Microsoft Download Center at http://go.microsoft.com/fwlink/?LinkID=242919&clcid=0x409.

To install the full installation of Microsoft .NET Framework 4.0, see “Microsoft .NET Framework 4” on the Microsoft Download Center at http://go.microsoft.com/fwlink/?LinkID=212931.

What is a PowerShell Module and what is a PowerShell Snap-In?

PowerShell Module

http://msdn.microsoft.com/en-us/library/windows/desktop/dd878324(v=vs.85).aspx

Script Modules

A script module is a file (.psm1) that contains any valid Windows PowerShell code. Script developers and administrators can use this type of module to create modules whose members include functions, variables, and more.

Binary Modules

A binary module is a .NET Framework assembly (.dll) that contains compiled code. Cmdlet developers can use this type of module to create modules that contain cmdlets, providers, and more. (Existing snap-ins can also be used as binary modules.)

 

A binary module is a .NET Framework assembly (.dll) that contains compiled code. Cmdlet developers can use this type of module to create modules that contain cmdlets, providers, and more. (Existing snap-ins can also be used as binary modules.)

 

PowerShell Snap-In

http://www.wrox.com/WileyCDA/Section/Extending-Windows-Powershell-with-Snap-ins.id-320555.html

Windows PowerShell provides an extensible architecture that allows new functionality to be added to the shell. This new functionality can be in the form of cmdlets, providers, type extensions, format metadata, and so on. A Windows PowerShell snap-in is a .NET assembly that contains cmdlets, providers, and so on. Windows PowerShell comes with a set of basic snap-ins that offer all the basic cmdlets and providers built into the shell. You write a snap-in when you want your cmdlets or providers to be part of the default Windows PowerShell. When a snap-in is loaded in Windows PowerShell, all cmdlets and providers in the snap-in are made available to the user. This model allows administrators to customize the shell by adding or removing snap-ins to achieve precise sets of providers and cmdlets…

Any .NET assembly becomes a Windows PowerShell snap-in when the assembly implements a snap-in installer class. Windows PowerShell supports two distinct types of snap-in installer classes. The default recommended type is PSSnapin, which registers all cmdlets and providers in a single contained assembly.

 

Share:

Leave a reply

− six = one

This site uses Akismet to reduce spam. Learn how your comment data is processed.