Académique Documents
Professionnel Documents
Culture Documents
Section Objectives
Section Overview
Windows PowerShell allows for automation in a more powerful form than previous scripting
methods such as VBScript or batch files. This section explains how to navigate and use basic
Windows PowerShell commands and how to use Windows PowerShell to manage Group
Policy.
It also explains how you can use PowerShell logon scripts with Group Policy.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize=
1/16
16/11/2014
Important Terms
Cmdlets are single-function tools built into the shell.
As with the command-prompt, Windows PowerShell gives you access to the file system on
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize=
2/16
16/11/2014
the computer. Additional Windows PowerShell providers enable you to access the registry and
the digital signature certificate stores as easily as you access the file system.
Windows PowerShell also allows the management of roles in Windows Server 2008 and later,
such as IIS 7.0, Terminal Server, Microsoft Exchange Server 2007 and Microsoft Operations
Manager 2007. Third-party vendors have also provided Windows PowerShell commands that
improve manageability.
This topic describes the features of Windows PowerShell. It explains the different ways that
you can use Windows PowerShell, and finally, how to use the tool.
3/16
16/11/2014
Commands that follow standard naming conventions and work with a small set of intuitive
utilities (where, select, sort, format, measure, compare, group) in order to provide
consistency and improve efficiency
Standardized tools for accessing many of the Windows data structures, including Active
Directory (ADSI) data, WMI, COM objects, ADO, HTML, and XML data
Simplified, command-based navigation of the operating system that lets users navigate the
registry, certificate store, and other data by using the same commands they use to navigate
the file system
New logging and error-handling capabilities for script execution tracking and error handling
Simple access to objects and system administration data, and the ability to pipe objects
between command-line tools
Extensible interface that allows third-party vendors to quickly build custom tools and
utilities to administer Windows
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize=
4/16
16/11/2014
Managing services, processes, registry, and WMI data: Common administration tasks,
such as enumerating running services or processes, viewing the registry, and modifying data
stored in WMI, are simplified with the built-in command-line tools.
Terminal Server management: Through data stored in WMI, Windows PowerShell scripts
can automate Terminal Server configuration changes. With Windows PowerShell you can
easily automate the management of Terminal Server farms.
Managing IIS 7.0: Windows PowerShell is a powerful tool for managing IIS 7.0 (Internet
Information Services 7.0) and you can use it to manage any aspect of IIS 7.0, including
deploying and configuring IIS 7 across a Web farm.
Managing Group Policy: You can now use Windows PowerShell to create and manage
group policy with a new library of cmdlets.
Logon Scripts: Since Windows PowerShell is installed by default on Windows 7 and later,
you can now use it for logon scripts in those operating systems.
And much more! There are so many new capabilities of PowerShell 3.0 that it is
impossible to cover them all in the one section. PowerShell ultimately has the ability to
perform most of the activities available in the graphical interface and more.
5/16
16/11/2014
6/16
16/11/2014
in Windows PowerShell.
This lists all available cmdlets to an HTML conversion cmdlet and outputs the results to a
Web page called cmdlets.htm. It then launches the Web page using the registered handler of
.htm files.
The pipe symbol | tells PowerShell to send the object output of one cmdlet to the next
cmdlet in line. The semicolon ; tells PowerShell to execute the next command as a separate
command, as if it were typed on a separate line.
Writing Scripts
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize=
7/16
16/11/2014
Add-PSSnapin
session.
Clear-History
Clear-Host
Connect-PSSession
Disable-PSRemoting
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize=
8/16
16/11/2014
PowerShell
commands.
Disable-
PSSessionConfiguration
computer.
Disconnect-PSSession
Enable-PSRemoting
Enable-
PSSessionConfiguration
Enter-PSSession
Exit-PSSession
Export-Console
Export-ModuleMember
ForEach-Object
Get-Command
Get-Help
concepts.
Get-History
Get-Job
session.
Get-PSSessionConfiguration Gets the session configurations registered on the computer.
Get-PSSnapin
Get-Verb
Import-Module
Invoke-Command
Invoke-History
New-Module
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize=
9/16
16/11/2014
New-ModuleManifest
New-PSSession
New-
PSSessionConfigurationFile
New-PSSessionOption
New-PSTransportOption
configuration.
Out-Default
Sends the output to the default formatter and the default output
cmdlet. It is a placeholder that lets you write your own Out-Default function or cmdlet.
Out-Host
Out-Null
Receive-Job
current session.
Register-
PSSessionConfiguration
Remove-Job
Remove-Module
Remove-PSSession
Remove-PSSnapin
Resume-Job
Save-Help
Set-PSDebug
Turns script debugging features on and off, sets the trace level
and
script blocks.
Start-Job
Stop-Job
Suspend-Job
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize
10/16
16/11/2014
Test-ModuleManifest
module.
Test-
PSSessionConfigurationFile
Unregister-
PSSessionConfiguration
Update-Help
Wait-Job
Where-Object
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize
11/16
16/11/2014
To see this list of Group Policy related commands, open Windows PowerShell and type getcommand -module grouppolicy. This will display a list of all the cmdlets (Figure 144) that
are available in the Group Policy module.
12/16
16/11/2014
Windows PowerShell logon scripts can be far more powerful than their batch file and
VBScript counterparts. With PowerShell, you can map drives, create shortcuts, change
registry values, create activity logs, copy files, map printers and much more! The code for
performing these operations is often simpler than VBscript.
The built-in PowerShell ISE is invaluable in assisting you when creating any kind of
PowerShell script. It supports colorized code, intellisense and code completion.
There are also third-party tools can help you to create and manage Windows PowerShell
logon scripts:
Specops Command (http://www.specopssoft.com)
Admin Script Editor (ASE) (http://adminscripteditor.com)
PowerGUI (http://www.powergui.org)
Acronyms
The following acronyms are used in this section:
ACL
ADO
ADSI
ASE
CLR
COM
GPO
WMI
Windows Management
Instrumentation
XML
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize
13/16
16/11/2014
Section Review
Summary
Some of the Windows PowerShell features are:
Cmdlets for performing administrative tasks
Scripting language that accelerates automation of repetitive tasks due to its integration
with the command-line shell
Support for existing scripts, existing command-line tools, and multiple operating systems
Commands that follow standard naming conventions and work with a small set of
intuitive utilities
Simple access to objects and system administration data, and the ability to pipe objects
between command-line tools
Extensible interface that allows third-party vendors to quickly build custom tools and
utilities to administer applications running Windows
You should know how to perform some of the following basic Windows PowerShell tasks:
Open Windows PowerShell: Three different methods: 1) Click Start, All Programs,
Windows PowerShell, and Windows PowerShell shortcut. 2) Type powershell at the
command prompt. 3) Click Start, select Run, and type powershell.
Chain commands: Chain several commands together on the same line.
Write scripts: Compose scripts at the command-line within Windows PowerShell.
Run scripts: Type the full path to the file, or, if the current directory is where the scripts
are located, type .\ before the file name.
To access the Windows PowerShell library for Group Policy, first load the Group Policy
module (open Windows PowerShell and type import-module grouppolicy). To display
the list of Group Policy commands, open Windows PowerShell and type get-command https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize
14/16
16/11/2014
module grouppolicy.
Some of the third-party Windows PowerShell-based logon script tools are:
Specops command
Admin Scipt Editor
PowerGUI
Knowledge Check
1.
What must you do in Windows PowerShell before you can display the list of Group
Policy commands?
2.
Which of the following is a feature of Windows PowerShell? (Choose all that apply.)
a.
Simple access to objects and system administration data, and provides the ability to
pipe objects between command-line tools
b.
c.
d.
Logging and error-handling capabilities for script execution tracking and error
handling
3.
4.
What must you do in Windows PowerShell before you can display the list of Group
Policy commands?
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize
15/16
16/11/2014
Which of the following is a feature of Windows PowerShell? (Choose all that apply.)
a.
Simple access to objects and system administration data, and provides the
ability to pipe objects between command-line tools
b.
c.
d.
3.
4.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b6175ac1-149e-4f52-83bd-6350c9133320?ChapterNumber=7&FontSize
16/16