Windows 7 is going to be the first operating system that actually ships with Windows PowerShell (rather than having to install PowerShell separately) and comes with the new PowerShell V2. Enough great reasons to take a closer look.
Ín this first part of what is going to be an ongoing series, we start small. You will only learn about one new V2 feature: Modules. You will, however, get all the information you need to start playing with PowerShell on W7. As we continue, we dive deeper and eventually touch all of the new features - and believe me, there are a lot!
Pinning PowerShell
To launch PowerShell, you could press WIN+R and enter powershell. That's ok. That's how we did it with the old console, too. However, in W7 there are smarter ways.
One is to pin PowerShell to the new taskbar. Simply right-click the PowerShell icon in the taskbar (which appears automatically once you launch PowerShell) and choose "Pin this program to the taskbar". That's it. Now, you got a PowerShell icon in your taskbar, and it stays there even if no PowerShell window is open anymore. And yes, pinning an application to the taskbar has a *lot* of additional advantages, it's not just good for making applications more accessible. Hang in a second.
You first may want to move the new PowerShell icon in your taskbar more to the left. It is more organized that way when all pinned applications are located on the left side. If you do move the PowerShell icon to the very first position in your taskbar, you now can even launch PowerShell without touching the mouse, simply by pressing WIN+1 (and, uhm, yes, you can press WIN+2 if it is the second icon in your taskbar. Go figure.).
Pinning PowerShell to the taskbar makes the console prettier, too. It will launch with the typical blueish background and in a larger console. Even more benefits are waiting for you in its new jump list. Right click your PowerShell icon (or drag it towards the desktop) to open the jump list. It contains all the commands you may ever need to launch PowerShell: launch it with or without administrator privileges, launch the PowerShell ISE, launch it with all modules auto-imported, or simply open the electronic manual. Hey, that's a convenient one-stop-shop.
Exploring Modules
Windows 7 includes not just PowerShell V2 but also comes with a number of modules. Modules are new in PowerShell V2. They are actually extensions much similar to the V1 Snapins. Unlike Snapins, Modules do not require installation. To see the modules Windows brings along, fire up this command:
Get-Module -ListAvailable
Windows 7 comes with these modules preconfigured: AppLocker (allows you to control which applications and installation packages a user can run, based on local or domain-wide policies), BitsTransfer (opens up the intelligent background transfer service to you so you can silently upload and download large files in the background), PSDiagnostics and TroubleshootingPack (which both refer to the built-in PowerShell-based self-diagnosis we will cover later). You may also see a module named GroupPolicy which comes with the R2 GPMC and enables you to view, analyze and even create group policy objects and links.
There are even more modules available when you install RSAT for Windows 7. RSAT (Remote Server Administration Tools) is like adminpak.msi in earlier windows versions and installs all the administration tools you may be used to. In addition, it also installs a module called ActiveDirectory with tons of Cmdlets to manage your Active Directory - finally!
Watch out: Once you downloaded and installed RSAT, the Active Directory module still isn't there. It is not installed by default. You need to open control panel first, go to Software and then look at the available Windows features. In this list, you will eventually find the Remote Server Administration Tools, and when you dig deeper into its options, you stumble over the PowerShell ActiveDirectory module. Check it, and click OK. A minute later, PowerShell finds and lists the new ActiveDirectory module.
Using Modules
Before you can use a module, you need to import it using Import-Module. So for example, to use the new Cmdlets contained in the AppLocker module, fire up this one:
Import-Module AppLocker
Or, you open the jump list of your pinned powershell console as described earlier and open PowerShell with all available modules preloaded automatically. Note however that this console will also enable all Admin rights.
To check out which new Cmdlets you got, use this line:
Get-Command -Module AppLocker
And to see a bunch of real-life scenarios and examples, simply extend the line and use the good old pipeline to pipe the Cmdlets to Get-Help:
Get-Command -Module AppLocker | Get-Help -example
What's Next?
I guess this is a pretty quick start to begin playing. You now know how to pin PowerShell, open it with and without admin privileges and modules. You also know how to find out which modules exist, which commands exist in each module, and how to get help for them. Ain't enough? In the next part, we'll look at remoting and how to enable it in a simple peer-to-peer test environment:
Part 2: Make remoting work in Windows 7
Have a great weekend!
Tobias
Posted
Jul 16 2009, 05:47 PM
by
Tobias