Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.

Similar presentations


Presentation on theme: "Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based."— Presentation transcript:

1 Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based Logon Scripts Managing Windows Environments with Group Policy

2 © 2013 Global Knowledge Training LLC. All rights reserved. Section Objectives After completing this section, you will be able to: Describe the Windows PowerShell features Explain how to perform the basic Windows PowerShell operations Explain how to access the Windows PowerShell library for Group Policy List the third-party Windows PowerShell-based logon script tools 6-2

3 © 2013 Global Knowledge Training LLC. All rights reserved. Introducing Windows PowerShell 6-3 Windows PowerShell Features Windows PowerShell Scenarios Using Windows PowerShell

4 © 2013 Global Knowledge Training LLC. All rights reserved. Windows PowerShell Features Thousands of cmdlets Scripting language to accelerate automation Support for existing scripts and tools Standard naming conventions for commands Access to ADSI, WMI, COM, ADO, HTML, and XML data Command-line navigation of the file system, registry, certificate store, and more Robust logging and error-handling Access to object and system administration data Extensible interface for third-party development 6-4

5 © 2013 Global Knowledge Training LLC. All rights reserved. Windows PowerShell Scenarios Managing services, processes, registry, and WMI data Terminal Server management Managing IIS 7.0 Managing Group Policy Logon Scripts And much more! PS C:\> 6-5

6 © 2013 Global Knowledge Training LLC. All rights reserved. Using Windows PowerShell Opening Windows PowerShell Chaining commands Writing Scripts Running Scripts Core Cmdlets PS C:\> 6-6

7 © 2013 Global Knowledge Training LLC. All rights reserved. Opening Windows PowerShell Open Windows PowerShell in many different ways: Run it from the Start, All Programs, Windows PowerShell, Windows PowerShell shortcut. Type powershell at a command prompt. Use the PowerShell taskbar shortcut. Go to the Start screen and type PowerShell. PS C:\> 6-6

8 © 2013 Global Knowledge Training LLC. All rights reserved. Chaining Commands You can chain several commands together on the same line such as with the following command: get-command | convertto-html -property name,definition -title "Cmdlets" > cmdlets.htm ; invoke-item cmdlets.htm PS C:\> 6-7 The pipe symbol sends the output of one cmdlet to another. The semicolon symbol signifies the beginning of a new command.

9 © 2013 Global Knowledge Training LLC. All rights reserved. Writing Scripts PowerShell scripts can be saved with a *.ps1 extension or can be written directly at the PowerShell prompt. $a = get-service | select-object name, status foreach ($i in $a) { if ($i.status -eq "running") {write-host $i.name -foregroundcolor "green"} elseif ($i.status -eq "stopped") {write-host $i.name -foregroundcolor "white"} else {write-host $i.name} } 6-8 After typing multiple lines of code at the prompt, press Enter twice to execute the code block.

10 © 2013 Global Knowledge Training LLC. All rights reserved. Running Scripts By default, PowerShell does not allow scripts to be run for security reasons. The Execution Policy must be relaxed to allow scripts to run. Use Set-ExecutionPolicy to set one of the following levels: Restricted AllSigned RemoteSigned Unrestricted Bypass 6-9

11 © 2013 Global Knowledge Training LLC. All rights reserved. Core Cmdlets (1) Add-PSSnapin Adds one or more Windows PowerShell snap-ins to the current session. Clear-HistoryDeletes entries from the command history. Clear-HostDeletes entries from the command history. Connect-PSSessionReconnects to disconnected sessions. Disable-PSRemoting Prevents the computer from receiving remote Windows PowerShell commands. Disable- PSSessionConfiguration Denies access to the session configurations on the local computer. Disconnect-PSSessionDisconnects from a session. Enable-PSRemotingConfigures the computer to receive remote commands. Enable- PSSessionConfiguration Configures the computer to receive remote commands. Enter-PSSessionStarts an interactive session with a remote computer. Exit-PSSessionEnds an interactive session with a remote computer. Add-PSSnapin Adds one or more Windows PowerShell snap-ins to the current session. 6-9

12 © 2013 Global Knowledge Training LLC. All rights reserved. Core Cmdlets (2) Export-Console Exports the names of snap-ins in the current session to a console file. Export-ModuleMemberSpecifies the module members that are exported. ForEach-ObjectPerforms an operation against each of a set of input objects. Get-CommandGets all commands. Get-Help Displays information about Windows PowerShell cmdlets and concepts. Get-HistoryGets a list of the commands entered during the current session. Get-Job Gets Windows PowerShell background jobs (PsJobs) that are running in the current console. Get-Module Gets the modules that have been imported, or can be imported, into the current session. Get-PSSession Gets the Windows PowerShell sessions (PSSessions) in the current session. Get-PSSessionConfigurationGets the session configurations registered on the computer. Get-PSSnapinGets the Windows PowerShell snap-ins on the computer. Get-VerbGets approved Windows PowerShell verbs. 6-10

13 © 2013 Global Knowledge Training LLC. All rights reserved. Core Cmdlets (3) Import-ModuleAdds modules to the current session. Invoke-CommandRuns commands on local and remote computers. Invoke-HistoryRuns commands from the session history. New-ModuleCreates a new dynamic module that exists only in memory. New-ModuleManifestCreates a new module manifest. New-PSSessionCreates a persistent connection to a local or remote computer. New- PSSessionConfigurationFile Creates a file that defines a session configuration. New-PSSessionOptionCreates an object that contains advanced options for a session. New-PSTransportOption Creates an object that contains advanced options for a session 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-HostSends output to the console. Out-NullDeletes output instead of sending it to the console. 6-10

14 © 2013 Global Knowledge Training LLC. All rights reserved. Core Cmdlets (4) Receive-Job Gets the results of the Windows PowerShell background jobs in the current session. Register- PSSessionConfiguration Creates and registers a new session configuration. Remove-JobDeletes a Windows PowerShell background job. Remove-ModuleRemoves modules from the current session. Remove-PSSessionCloses one or more Windows PowerShell sessions (PSSessions). Remove-PSSnapinRemoves Windows PowerShell snap-ins from the current session. Resume-JobRestarts a suspended job. Save-HelpDownloads and saves the newest help files to a file system directory. Set-PSDebug Turns script debugging features on and off, sets the trace level and toggles strict mode. Set-PSSessionConfigurationChanges the properties of a registered session configuration. Set-StrictMode Establishes and enforces coding rules in expressions, scripts, and script blocks. Start-JobStarts a Windows PowerShell background job. 6-11

15 © 2013 Global Knowledge Training LLC. All rights reserved. Core Cmdlets (5) Receive-Job Gets the results of the Windows PowerShell background jobs in the current session. Register-PSSessionConfiguration Creates and registers a new session configuration. Remove-Job Deletes a Windows PowerShell background job. Remove-Module Removes modules from the current session. Remove-PSSession Closes one or more Windows PowerShell sessions (PSSessions). Remove-PSSnapin Removes Windows PowerShell snap-ins from the current session. Resume-Job Restarts a suspended job. Save-Help Downloads and saves the newest help files to a file system directory. 6-11/12 Stop-JobStops a Windows PowerShell background job. Suspend-JobTemporarily stops workflow jobs. Test-ModuleManifest Verifies that a module manifest accurately describes the contents of a module. Test- PSSessionConfigurationFile Verifies the keys and values in a session configuration file. Unregister- PSSessionConfiguration Deletes a registered session configurations from the computer. Update-HelpDownloads and installs the newest help files on your computer. Wait-Job Suppresses the command prompt until one or all of the Windows PowerShell background jobs are complete. Where-Object Creates a filter that controls which objects will be passed along a command pipeline.

16 © 2013 Global Knowledge Training LLC. All rights reserved. Windows PowerShell Library for Group Policy A Windows PowerShell library for Group Policy is now available. import-module grouppolicy get-command -module grouppolicy 6-13

17 © 2013 Global Knowledge Training LLC. All rights reserved. Windows PowerShell Cmdlets for Group Policy 6-13 Invoke-GPUpdateGet-GPPermissionsRemove-GPRegistryValue Get-GPResultantSetOfPolicySet-GPPermissionsRename-GPO Backup-GPOImport-GPORestore-GPO New-GPOCopy-GPOSet-GPInheritance New-GPLinkGet-GPPermissionSet-GPLink Get-GPOGet-GPInheritanceSet-GPPermission Get-GPOReportNew-GPStarterGPOSet-GPPrefRegistryValue Get-GPStarterGPORemove-GPLinkSet-GPRegistryValue Get-GPPrefRegistryValueRemove-GPO Get-GPRegistryValue Remove- GPPrefRegistryValue Below are the CmdLets specific to Group Policy:

18 © 2013 Global Knowledge Training LLC. All rights reserved. Windows PowerShell-Based Logon Scripts Windows 7 and later allow for Windows PowerShell- based logon scripts. Windows PowerShell is enabled by default in Windows 7 and Windows Server 2008 R2. Windows PowerShell Logon Scripts allow for more powerful logon scripts. Use PowerShell ISE to create and edit scripts Other third-party editing tools include: Specops Command (http://www.specopssoft.com) Admin Script Editor (ASE) (http://adminscripteditor.com) PowerGUI (http://www.powergui.org) 6-14

19 © 2013 Global Knowledge Training LLC. All rights reserved. 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 6-16

20 © 2013 Global Knowledge Training LLC. All rights reserved. Summary (cont.) 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 Server 2008 6-16

21 © 2013 Global Knowledge Training LLC. All rights reserved. Summary (cont.) 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 the 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. 6-16

22 © 2013 Global Knowledge Training LLC. All rights reserved. Summary (cont.) 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 -module grouppolicy. Some of the third-party Windows PowerShell-based logon script tools are: Specops command Admin Scipt Editor PowerGUI 6-16

23 © 2013 Global Knowledge Training LLC. All rights reserved. Knowledge Check 1.What must you do in Windows PowerShell before you can display the list of Group Policy commands? Load the Group Policy module 6-17

24 © 2013 Global Knowledge Training LLC. All rights reserved. Knowledge Check (cont.) 2.Which of the following is a feature of Windows PowerShell? a.Simple access to objects and system administration data, and provides the ability to pipe objects between command-line tools b.Cmdlets for performing administrative tasks c.Run PowerShell commands against Windows 2000 operating systems d.Logging and error-handling capabilities for script execution tracking and error handling 6-17

25 © 2013 Global Knowledge Training LLC. All rights reserved. Knowledge Check (cont.) 3.Which extension is used to save a Windows PowerShell script file?.ps1 4.List some of the third-party Windows PowerShell- based logon script tools. Specops command Admin Scipt Editor PowerGUI 6-17


Download ppt "Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based."

Similar presentations


Ads by Google