PowerShell manages win Server 2008 R2_powershell

Source: Internet
Author: User
Tags sessions

Windows PowerShell is a command line interface and scripting language designed specifically for system management. Built on top of the Microsoft. NET Framework, Windows PowerShell can help IT professionals automate the Windows (R) operating system and manage applications running on Windows.

The Windows PowerShell command (called a cmdlet) allows you to manage computers in your enterprise from the command line. The Windows PowerShell provider makes it easy to access data stores, such as the registry and certificate stores, as you would access the file system.

In Windows Server 2008 R2, the cmdlet that manages roles or features is encapsulated in the provider's module and is encapsulated in the Windows PowerShell snap-in if you need to use Windows PowerShell 1.0 for parity. Unlike the GUI, you can combine multiple modules and snap-in in a Windows PowerShell session to simplify the management of multiple roles and functions.

Install role-based or functional modules and snap-in using Server Manager

After you install Windows Server 2008 R2, you can use the cmdlet associated with it. When the appropriate roles or features are installed through Server Manager, the cmdlet associated with the server roles or features available in Windows Server 2008 R2 is installed as part of a module or snap-in.

Start a Windows PowerShell session with all available Windows PowerShell modules and snap-in

After you install Windows PowerShell, you must import a module or add a registered snap-in before you can use the cmdlet associated with that role or feature. You will not be able to use or view Help for the cmdlet that is included in a specific module or snap-in for a role or feature until you import the module or add a snap-in to a Windows PowerShell session.

You can import multiple modules or snap-in to a Windows PowerShell session. To simplify administration, you can automatically import all modules and add all registered snap-in when you start a session.

Start the Windows PowerShell session using all available Windows PowerShell modules and snap-in, as follows:

1. Click Start, All Programs, administrative Tools, and then click Windows PowerShell module.

2. If the User Account Control dialog box appears, make sure that it displays the action you want to perform, and then click Yes.

Get-module: Lists all modules that have been imported to the Windows PowerShell session

After you start a Windows PowerShell session, you may want to list all the modules that have been imported into the session. For example, you might want to verify that a module has been imported into the session or to find the module name that is used as a parameter for the cmdlet. To list all imported modules, type "Get-module" at the Windows PowerShell prompt, and then press Enter.

Get-pssnapin: Lists all snap-in sessions that have been added to a Windows PowerShell session

To list all the added snap-in, type "Get-pssnapin" at the Windows PowerShell prompt, and then press ENTER.

Get-command-module: Lists all the cmdlet in a module or snap-in

After you import a module or add a snap-in to the current Windows PowerShell session, you can determine the administrative features that are available by listing the cmdlet that is supported by that module or snap-in. You can use the Get-command cmdlet to list the cmdlet that was added to the current session from the imported module or the registered snap-in. To list all the cmdlet in the imported module, type "Get-command-module modulename" at the Windows PowerShell prompt, and then press ENTER. Where ModuleName refers to the name of the imported module.

Get-command-module: Lists all the cmdlet in the registered snap-in that is added to the current Windows PowerShell session

To list all the cmdlet in the registered snap-in that you added to the current Windows PowerShell session, type "Get-command-module snap-inname" at the indows PowerShell prompt, and then press ENTER.

Where Snap-inname refers to the name of the registered snap-in that was added to the current session. For example, if you use Server Manager to install Windows Server Backup features Windows Server Backup and command line tools, and you have added the Windows.serverbackup snap-in to Windows PowerShell session, to list all the cmdlet in the Windows.serverbackup snap-in, at the indows PowerShell prompt, type Get-command–module Windows.serverbackup, and then press ENTER.

Get-help *ad*: Lists the cmdlet Help topics for the roles or features included in the imported module

You can list the Help topics for a cmdlet that supports roles or features by applying wildcard * and noun prefixes. These commands can be used to display Help for all cmdlet implementations for specific roles or features of Windows Server 2008 R2.

For example, the Active directory domain Service cmdlet uses "AD" as a noun prefix in the cmdlet name.

To list all the Help topics for the Active Directory domain service after you import the ActiveDirectory module, type "Get-help *ad*" at the Windows PowerShell prompt, and then press ENTER.

Get-module–listavailable: Lists all installed modules that can be imported into a Windows PowerShell session

Before you import a module into a Windows PowerShell session, you will need to know the name of the module. To list all installed modules, type "get-module–listavailable" at the Windows PowerShell prompt, and then press ENTER.

Get-pssnapin–registered: Lists all registered snap-in sessions that can be added to a Windows PowerShell session

Before you add a registered snap-in to a Windows PowerShell session, you will need to know the name of the snap-in. To list all registered snap-in units, type "get-pssnapin–registered" at the Windows PowerShell prompt, and then press ENTER.

Import-module: Import a single module into a Windows PowerShell session

Sometimes, you may want to import a module into an existing Windows PowerShell session. For example, if you install a role or feature after you start a Windows PowerShell session, the module associated with the newly installed role or feature will not be available until the module is imported into the started session. To import a single module, type "Import-module modulename" at the Windows PowerShell prompt, and then press ENTER.

Where ModuleName refers to the name of the available module. For example, if you installed the Active Directory domain service role to import a activedirectory module into a Windows PowerShell session, at the Windows PowerShell prompt, type Import-module ActiveDirectory, and then press ENTER.

Add-pssnapin: Add a registered snap-in to a Windows PowerShell session

Roles or features can install and register the Windows PowerShell snap-in, rather than modules, to remain compatible with the cmdlet implemented for previous versions of Windows PowerShell. If the cmdlet you want to use is already implemented in a snap-in, you will need to add the snap-in to make the cmdlet available for the current session. To add a registered snap-in to the current Windows PowerShell session, type "Add-pssnapin snap-inname" at the Windows PowerShell prompt, and then press ENTER.

Where Snap-inname refers to the name of a snap-in that has been installed and registered. For example, if you use Server Manager to install Windows Server Backup features: Windows Server Backup and command-line tools, you can type the Add-pssnapin at the Windows PowerShell prompt by typing Windows.serverbackup, and then press ENTER to add the Windows.serverbackup snap-in to the Windows PowerShell session.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.