Upload
hugo-hoover
View
234
Download
0
Tags:
Embed Size (px)
Citation preview
Windows PowerShell for Beginners
Jeffrey SnoverDistinguished Engineer/Lead Architect for Windows Server
Mir RosenbergSenior Program ManagerMicrosoft Corporation
WSV315
Agenda
Introduce Windows PowerShellLearning to learn PowerShellDrill into utility cmdletsWord from PowerShellCommunity.orgQ&A!Have some FUN!
Windows PowerShell
Command line and scripting languageAs interactive and composable as BASH/KSH
As programmatic as Perl/Python/Ruby
As production oriented as AS400 CL/VMS DCL
Common Engineering Criteria70+ active internal partners
Lync Server • SharePoint Server • Service Manager • Windows Small Business Server • Exchange Server • Windows Diagnostics • Server Manager • SQL Server • Active Directory • Failover Clustering • System Center Operations Manager • Windows Backup • Server Migration • System Center Virtual Machine Manager • Best Practices Analyzer • Active Directory Rights Management Services • Internet Information Services • Background Intelligent Transfer Service • System Center Data Protection Manager • Network Load Balancing • Remote Desktop Services • Group Policy • WS-Management • AppLocker • WMI
Productivity
Exchange 2003 (VBScript) Exchange 2007 (PowerShell)
Mailbox Stats
Set listExchange_Mailboxs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\MicrosoftExchangeV2").InstancesOf("Exchange_Mailbox")
For Each objExchange_Mailbox in listExchange_MailboxsWScript.echo "AssocContentCount =” + objExchange_Mailbox.AssocContentCountWScript.echo " DateDiscoveredAbsentInDS =” + objExchange_Mailbox.DateDiscoveredAbsentInDSWScript.echo " DeletedMessageSizeExtended =” + objExchange_Mailbox. DeletedMessageSizeExtendedWScript.echo " LastLoggedOnUserAccount =” + objExchange_Mailbox. LastLoggedOnUserAccountWScript.echo " LastLogoffTime =” + objExchange_Mailbox. LastLogoffTimeWScript.echo " LastLogonTime =” + objExchange_Mailbox. LastLogonTime WScript.echo " LegacyDN =” + objExchange_Mailbox. LegacyDNWScript.echo " MailboxDisplayName =” + objExchange_Mailbox. MailboxDisplayNameWScript.echo " MailboxGUID =” + objExchange_Mailbox. MailboxGUID WScript.echo " ServerName =” + objExchange_Mailbox. ServerName WScript.echo " Size =” + objExchange_Mailbox. SizeWScript.echo " StorageGroupName =” + objExchange_Mailbox. StorageGroupName WScript.echo " StorageLimitInfo =” + objExchange_Mailbox. StorageLimitInfo WScript.echo " StoreName =” + objExchange_Mailbox. StoreName WScript.echo " TotalItems =” + objExchange_Mailbox. TotalItems Next
get-mailboxstatistics –server $servername
DatabaseMgmt
Dim StorGroup as New CDOEXM.StorageGroup
StorGroup.DataSource.Open "LDAP://" + DCServer + "/ CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName
StorGroup.MoveLogFiles("C:\newlogPath", 0)
move-storagegrouppath -identity “First Storage Group“ –log "C:\newlogPath”
Recipient Mgmt
Dim objMailbox As CDOEXM.IMailboxStore
Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName)
objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName
enable-mailbox -identity domain\FOO –database “First Storage Group\Private MDB”
Objects“An object is a collection of parts
and how to use them”
PartsProperties
Front Wheel
Back Wheel
Pedals
Saddle
Frame
How to useMethods
Pedal
Steer Left
Steer Right
Apply Front Brake
Apply Rear Brake
Parts How to use
Objects
DisplayName
PartsProperties
Status
RequiredServices
Stop()
How to useMethods
Start()
Pause()WindowsService
The Difference is OBJECTS!
Get-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table
Get-P
rocess
Cm
dlet
Common Windows PowerShell Parser
Windows PowerShell Pipeline Processor
Wh
ere C
md
let
So
rt C
md
let
Fo
rmat
Cm
dlet
Learn and Leverage
In-box documentsPowerShell_ISE HelpGetting StartedUser’s GuideAbout HelpCmdlet Help Provider Help
Discovery utilitiesBooksCommunity
Practice ad hoc development
Command FunctionGet-Help Help about PowerShell commands and topicsGet-Command Get information about anything that can be invokedGet-Member Show what can be done with an objectGet-Module Shows packages of commands
Utilities - Discovery
Command Action
Compare Compare 2 sets of objects
Foreach Act on each element of a set
Group Split a set of objects into groups
Measure Measure some property of a set of objects
Select Select a set of properties from a set of objects
Sort Sort objects
Tee Make a copy of a set of objects
Where Select a subset of objects
Utilities – Object Manipulation
Object Manipulation Utilities
Jeffrey SnoverDistinguished Engineer / Lead ArchitectWindows Server demo
Summary / Call to Action
Available at: www.microsoft.com/downloadsSearch for PowerShell
Try it, Deploy it, Use it, Share it!Focus on learning to learn
Automate and Prosper!
Windows PowerShell Community Resources
Team blog: http://blogs.msdn.com/PowerShellPowerShell Community: http://www.powershellcommunity.orgPowerShell Forum: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads Channel 9: http://channel9.msdn.com/tags/PowerShellWiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWikiScript Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspxCodePlex: http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershellSome good books
PowerShell in Action, 2nd Edition by Bruce Payettehttp://www.manning.com/payette2 Windows PowerShell Cookbook, 2nd Edition by Lee Holmes http://oreilly.com/catalog/9780596801519/ PowerShell Comics! http://borntolearn.mslearn.net/comics/b/weblog/archive/2011/04/20/climbing-mt-powershell-comic-book-first-pages.aspx
Related ContentBreakout Sessions
WSV406 | Advanced Automation Using Windows PowerShell 2.0 WSV316 | WS08R2: Tips on Automating the Breadth of Your IT Environment WCL321 | Windows PowerShell Remoting: Definitely NOT Just for Servers WSV322 | Managing the Registry with Windows PowerShell 2.0WSV471-INT | Build Reusable Tools in Windows PowerShellWSV473-INT | Windows PowerShell 3.0: Why Wait? Get Next-Generation PowerShell…EXL321 | Microsoft Lync Server 2010: Administering Lync Server Deployment
Hands-on LabsWSV276-HOL Introduction to Windows PowerShell Fundamentals WSV371-HOL Advanced Windows PowerShell Scripting WSV378-HOL Server Management and Windows PowerShell V2
Product Demo Stations WSV 1 – Windows PowerShell and Server Management
Track Resources
Don’t forget to visit the Cloud Power area within the TLC (Blue Section) to see product demos and speak with experts about the Server & Cloud Platform solutions that help drive your business forward.
You can also find the latest information about our products at the following links:
Windows Azure - http://www.microsoft.com/windowsazure/
Microsoft System Center - http://www.microsoft.com/systemcenter/
Microsoft Forefront - http://www.microsoft.com/forefront/
Windows Server - http://www.microsoft.com/windowsserver/
Cloud Power - http://www.microsoft.com/cloud/
Private Cloud - http://www.microsoft.com/privatecloud/
Resources
www.microsoft.com/teched
Sessions On-Demand & Community Microsoft Certification & Training Resources
Resources for IT Professionals Resources for Developers
www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
Learning
http://northamerica.msteched.com
Connect. Share. Discuss.
© 2011 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.