corey hynes hynesite, inc session code: srv317 objectives let you walk out of here, being able to...

33

Upload: nancy-theodora-tyler

Post on 17-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some
Page 2: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Managing Windows Server 2008 R2 and Windows 7 with Windows PowerShell V2

Corey HynesHynesITe, IncSession Code: SRV317

Page 3: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Objectives

Let you walk out of here, being able to run a script against an OU of computers, to make some sort of global configuration change

Page 4: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Assumption

You understand fundamental PowerShellYou are willing to learn how to write code

Page 5: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

What will we cover?

PowerShell V2 toolsRemotingModules

Lots of details about individual modulesPowerShell code to run commands against multiple computersTips and TricksLots of Demos

Page 6: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

PowerShell, why you should care?

New model for administration and administrative toolsGives ITPro’s the same ability as a developer to manipulate WindowsGUI now runs on PowerShellScripts, samples, guidance, all come as PowerShell scripts

Page 7: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Tools

PowerShell ConsolePowerShell ISEModulesRemotingForms

Page 8: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

PowerShell ISE

Simplify authoring of scripts

SaveExecute partial scriptsDebugColor coding

Default on Win7Add to R2

Page 9: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Remoting

This is what makes this session possibleModule: None, build in.Key Cmdlets

Invoke-CommandNew-PSSessionEnter-PSSessionExit-PSSession

NotesMust be enabled, GUI or Enable-PSRemoting

Page 10: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

RunSpace

IP LAN

ScriptBlock

Conceptual Model of Remoting

Get-Service Results

Page 11: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Working in Interactive Sessions

Key CmdletsEnter-PSSession to start a new sessionExit-PSSession to end a new session

Session objectsNew-PSSession

NoteInteractive sessions are not supported on Core

Page 12: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Modules

Discrete collections of cmdletsCan be authored and deployed to give you “packages” of functionalityStored in file system

System32\WindowsPoweshell\1.0\ModulesRoles and Features add new CmdletsYou can use a remote computer’s modules

Page 13: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Working with Modules

Import-Module to load a moduleGet-Module to load a moduleGet-Command –Module <Name> to see what is in a module

Page 14: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

How to perform some really simple and easy things…..

Managing Windows

Page 15: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

TroubleShooting Packs

Known as the “troubleshooters”Module: TroubleshootingpackKey Cmdlets

Get-Troubleshootingpack <path>Invoke-Troubleshootingpack <path>

NotesC:\Windows\Diagnostics\System contain build-in troubleshooting packs

Page 16: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Role and Feature Management

Replaces ServerManager.exeModule: ServerManagerKey Cmdlets

Get-WindowsFeature <FeatureName>Add-WindowsFeature <FeatureName>Properties Name, Parent, Installed, Dependson

NotesServer Core, have to add ServerManager-PSH-Cmdlets

Page 17: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Group Policy

Replaces: Lots of little tools and scriptsModule: GroupPolicy (part of GPMC)Key CmdLets

Get-GPO, New-GPOBackup-GPOCopy-GPOGet-GPOReport

NotesLimited ability to “edit” GPO.

Page 18: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Active Directory

Replaces: Scripts that were shipped with previous versionsModule: Active DirectoryKey CmdLets:

Way too many to listOver 75 Cmdlets

NotesRequires that you have one 2008 R2 DC running the AD Web Service

Page 19: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Best Practices

Replaces: Nothing, brand newModule: BestPracticesKey Cmdlets

Get-BPAModelInvoke-BPAModel

Notes:Not all roles have BPA models that can be run.Updates via Microsoft Update.

Page 20: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Additional Modules

ADRMS – Rights ManagementADRMSAdmin – Rights Management AdminAppLockerBitsTransferFailoverClustersRemoteDesktopSearvicesWebAdministrationNetworkLoadBalancing

Page 21: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Running commands across many systems

Scaling 1 to Many

Page 22: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Known Systems

If you know the names and quantity of your targetsUse Invoke-Command with –ScriptBlock and multiple computer names

Page 23: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Unknown Systems

If you do not know the names/quantityYou have to query for that information

Many optionsQuery from fileQuery from Active Directory

Query results in a collection of computer namesUse a foreach loop to pass instructions to each computer

Page 24: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Executing more Complicated Scripts

You can’t always write a One-LinerTo complexHard to read

Multi-line ScriptblockUse { and } with ; to separate the linesExectute the script

Page 25: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Loops

Key item to know is ForEach loopSimple Strucure

ForEach ($Object in $Objects) {$Object.DoSomething

}

Page 26: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Running “normal” commands

Not straight forwardNeed to combine command and parametersSuggestion

Shell using Cmd /CProvide/construct string as command to run

Page 27: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Configuration and Requirements

Page 28: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

How do I do this?

Enable remote managementServer Manager on WS08 R2PowerShell on ServerCorePowerShell on Win7

Firewall Rules and AuthenticationAuthentication is KerberosSecurity is WMI based securityFirewall rules Allow port 5985 for HTTP

Page 29: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

A word on Security

Big topic, not this sessionIn general

Authentication is Kerberos/NTLM or specifiedWire encryption can be HTTPS or IPSec

HTTPS part of WINRM configurationIPSec outside WINRM

Remoting disabled by defaultYou can restrict what remote sessions can do

Query data, make changes, all or none

Page 30: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Related Material

WSV08-HOL - Introduction to Windows PowerShell Fundamentals (40, 88, 3.14)WSV03-HOL - Advanced Windows PowerShell Scripting (38, 54, 3.19)WSV19-HOL - Windows Server 2008 R2: Server Management and Windows PowerShell V2 (39, 29, 3.34)WSV20-HOL - Windows Server 2008 R2: What's New in Microsoft Active Directory (38, 53, 2.76)

Page 31: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

Complete an evaluation on CommNet and enter to win an Xbox 360 Elite!

Page 32: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some
Page 33: Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,

IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.