woensdag 26 mei 2010 23:57
Kurt Roggen
Managing Windows Server 2008 R2 using PowerShell
In PowerShell v1 we used snapins to add functionality. These were dependant on the supplier creating an installer package so that the dll was registered correctly – otherwise its a manual job. PowerShell v2 introduced modules in which “libraries” of functions or dlls with cmdlets could be loaded.
Windows Server 2008 R2 comes with several PowerShell modules, allowing you to already manage most Server Roles and Features using PowerShell.
PowerShell is very straightforward/consistent and self-discoverable. With some of these basic commands, you will find any cmdlets out there…
To get a list of available PS modules, use the cmdlet Get-Module.
PS:\> Get-Module –ListAvailable

To use a module, use the cmdlet Import-Module
PS:\> Import-Module ActiveDirectory
To get the cmdlets imported from a module, use the Get-Command cmdlet with the –Module parameter
PS:\> Get-Command –Module ActiveDirectory
PS:\> Get-Command –Module ActiveDirectory –verb Get
PS:\> Get-Command –Module ActiveDirectory –noun ADuser
PS:\> Get-Command –Module ActiveDirectory –noun AD*
Here’s a list of available PS modules:
| Server Role/Server Feature | Module Name | PS Noun Keyword | # Cmdlets |
| Server Manager | import-Module ServerManager | WindowsFeature* | 3 |
| Active Directory Domain Services | import-module ActiveDirectory | AD* | 76 |
| Active Directory Rights Mgmt Services (RMS) | import-module ADRMS | ADRMS* | 3 |
| Failover Clusters | import-module FailoverClusters | Cluster* | 69 |
| Network Load Balanced (NLB) Clusters | import-module NetworkLoadBalancingClusters | NLB* | 35 |
| AppLocker | import-module AppLocker | AppLocker* | 5 |
| Group Policies/Preferences | import-module GroupPolicy | GP* | 25 |
| Remote Desktop Services | import-module RemoteDesktopServices | | 3 |
| Internet Information Services (IIS) 7.5 | Import-Module WebAdministration | Web* | 74 |
| Best Practices Analyzer (BPA) | Import-Module BestPractices | BPA* | 4 |
| Background Intelligent Transfer Service (BITS) | import-module BitsTransfer | BITS* | 8 |
| Windows Troubleshooting Wizards | import-module TroubleshootingPack | | 2 |
| PowerShell Diagnostics | import-module PSDiagnostics | | 10 |
Here’s a list of available PS Snapins:
| Windows Server Backup (WSB) | add-PSSnapin Windows.Serverbackup |
| Windows Server Migration Tools (SMIG) | add-PSSnapin Microsoft.Windows.ServerManager.Migration |
Other PS libraries/modules available are
| Hyper-V (codeplex) – see previous post |
| |
Filed under: WindowsServer2008R2, Powershell, Mgmt