SlideShare a Scribd company logo
PowerShell in the EnterpriseBest Practices for adopting PowerShell as the automation platform
About MeWork at Dell Inc.A Windows PowerShell MVPAuthor of:eGuide: A layman’s guide to PowerShell 2.0 remotingeGuide: WMI Query Language via PowerShellSharePoint 2010 PowerShell cheat sheet (for Quest)Automation is my passion
AgendaIntroductionChallengesDeploying & Securing PowerShellDeveloping & Validating ScriptsTools for the jobQ & A
Giving Away..PowerGUI Pro
IntroductionWindows PowerShell?Microsoft Common Engineering Criteria*..not just Microsoft anymore* http://www.microsoft.com/cec/en/us/cec-overview.aspx#man-windows
ChallengesProperly manage PowerShellSecure the IT environmentMake automation effective
Deploying PowerShellAvailable on Windows Server 2008 R2 and Windows 7, by defaultAvailable as an update (KB968929) for down level operating systems.Windows UpdateStandalone install
Securing PowerShellWhat is script execution policy?Types of Execution PolicyRestrictedAllSignedRemoteSignedUnrestrictedByPassSigning scripts
DEMOSecuring PowerShellExecution policy and signing scripts
Developing ScriptsStart with the shellThink Objects, not textImplement scripting standardsLook for code optimizationsInclude script documentationInclude debug or verbose information
DEMODeveloping ScriptsObject based shell and scripting standards
Developing ScriptsDon’t re-invent the wheelPoshCode.OrgPowershellcommunity.org#PowerShellTechnet Scripts CenterForums
Validating ScriptsValidate in a non-production environmentScript functionalityDesired output
Tools for the jobSeveral script editorsWindows PowerShell ISEPowerGUI Script EditorIdera PowerShellPlusDevFarm PowerSEVisual Studio for developing PowerShell ScriptsPowerGUI VSXDevelop Forms & WPF GUI
DEMOTools for the jobScript editors and Visual Studio
SummaryWindows PowerShell is the futureof datacenter automationBest practices and recommendations make your environment effectiveand securePowerShell community is growingand eager to help you
Thank YouEmail: Ravikanth@Ravichaganti.comBlog: http://www.ravichaganti.com/blogTwitter: http://www.twitter.com/ravikanth
© 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.

More Related Content

PPTX
PPTX
Challenges of automated mobile UI testing
PPT
How to do better Quality Assurance for Cross-Browser Testing
TXT
Read me!
PPTX
Angular 5,6,7
PPTX
客製化的 Web api 的框架設計
PPTX
Selenium Training - Eduxfactor.pptx
PDF
Selenium Training - Eduxfactor-converted.pdf
Challenges of automated mobile UI testing
How to do better Quality Assurance for Cross-Browser Testing
Read me!
Angular 5,6,7
客製化的 Web api 的框架設計
Selenium Training - Eduxfactor.pptx
Selenium Training - Eduxfactor-converted.pdf

What's hot (19)

PDF
Selenium Training - Eduxfactor-converted.pdf
PDF
Vue js & vue cli 3 plugins to boost up the performance of your application
PPTX
Extend Visual Studio 2010
PPTX
Cosa c'è di nuovo per l'Application Lifecycle Management in Visual Studio 2013
PPTX
Presentation for gips
PDF
What Is Selenium | Selenium Tutorial For Beginner | Selenium Training | Selen...
PPT
Automatic system tests of web applications
PDF
Android MVVM TDD
PPTX
07 the power in the shell - remoting
PPTX
Test driving an MVVM App
PPTX
Installing Plug-ins
PPTX
Installation of Silk Test Framework
PPTX
Upcoming new features of selenium in automation testing
PPTX
Visual Studio and Xamarin: The future of app development
PPTX
Walther Mvc
PPT
How ASP.NET MVC Implementation Help Enterprise Web Application Development?
PDF
Mvp pattern
PDF
Certificate
PDF
Selenium Training - Eduxfactor-converted.pdf
Vue js & vue cli 3 plugins to boost up the performance of your application
Extend Visual Studio 2010
Cosa c'è di nuovo per l'Application Lifecycle Management in Visual Studio 2013
Presentation for gips
What Is Selenium | Selenium Tutorial For Beginner | Selenium Training | Selen...
Automatic system tests of web applications
Android MVVM TDD
07 the power in the shell - remoting
Test driving an MVVM App
Installing Plug-ins
Installation of Silk Test Framework
Upcoming new features of selenium in automation testing
Visual Studio and Xamarin: The future of app development
Walther Mvc
How ASP.NET MVC Implementation Help Enterprise Web Application Development?
Mvp pattern
Certificate
Ad

Similar to PowerShell in the enterprise - TechED India 2011 (20)

PPTX
Introduction to PowerShell and getting started
PDF
PowerShell In 2024 And Beyond The Future Of Automation.pdf
PDF
Sql Server & PowerShell
PPTX
Wsv406 Advanced Automation Using Windows Power Shell2.0
PDF
PowerShell in Depth An administrator s guide Don Jones
PPTX
Holy PowerShell, BATman! - dogfood edition
PPTX
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
PDF
Power Shell For Testers
PPTX
PowerShellForDBDevelopers
PPTX
PowerShell Scripting and AI-infused Automation
PPTX
Introducing PowerShell 3.0
PPTX
Intro to Powershell
PPTX
Power shell basics day1
PPTX
Introduction to PowerShell (SharePoint Fest Chicago 2016 Workshop)
PPTX
SQL 2012 and Powershell for the Bleeding Edge DBA
PPTX
Top 10 PowerShell Features in Server 2012
PPT
Introduction to PowerShell
PPTX
Power shell training
PPTX
PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
Introduction to PowerShell and getting started
PowerShell In 2024 And Beyond The Future Of Automation.pdf
Sql Server & PowerShell
Wsv406 Advanced Automation Using Windows Power Shell2.0
PowerShell in Depth An administrator s guide Don Jones
Holy PowerShell, BATman! - dogfood edition
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
Power Shell For Testers
PowerShellForDBDevelopers
PowerShell Scripting and AI-infused Automation
Introducing PowerShell 3.0
Intro to Powershell
Power shell basics day1
Introduction to PowerShell (SharePoint Fest Chicago 2016 Workshop)
SQL 2012 and Powershell for the Bleeding Edge DBA
Top 10 PowerShell Features in Server 2012
Introduction to PowerShell
Power shell training
Windows Powershell in Action 1st Edition Bruce G. Payette
Ad

More from Ravikanth Chaganti (20)

PPTX
Azure Bicep - An Introduction
PPTX
Azure CLI 2.0 Tips and Tricks
PPTX
Tests Driven PowerShell Learning
PPTX
PowerShell Data as File System
PPTX
Azure at the command line
PPTX
Microsoft Azure Cloud and DevOps
PPTX
Using PowerShell DSC with AWS Cloud and CloudFormation
PPTX
Developing Infrastructure Code for CI & CD
PPTX
PowerShell DSC Partial Configurations and Cross-node Synchronization
PPTX
Operations Validation for Infrastructure As Code - PSConfEU 2016
PPTX
Authoring Azure Resource Manager Templates - Future Unleashed 2015
PPTX
Cloud Computing for IT professionals
PPTX
Introduction to Microsoft Azure Compute
PPTX
Cross platform configuration management using Desired State Configuration
PPTX
Windows Server 2012 R2 Hyper-V Replica
PPTX
Whats new in Windows Server 2012 R2 Hyper-V
PPTX
Configuration management comes to Windows
PPT
Desired state-configuration-ravikanth-august-2013-vtc india
PPTX
Power shell saturday ravikanth
PPTX
PowerShell 3.0 workflows
Azure Bicep - An Introduction
Azure CLI 2.0 Tips and Tricks
Tests Driven PowerShell Learning
PowerShell Data as File System
Azure at the command line
Microsoft Azure Cloud and DevOps
Using PowerShell DSC with AWS Cloud and CloudFormation
Developing Infrastructure Code for CI & CD
PowerShell DSC Partial Configurations and Cross-node Synchronization
Operations Validation for Infrastructure As Code - PSConfEU 2016
Authoring Azure Resource Manager Templates - Future Unleashed 2015
Cloud Computing for IT professionals
Introduction to Microsoft Azure Compute
Cross platform configuration management using Desired State Configuration
Windows Server 2012 R2 Hyper-V Replica
Whats new in Windows Server 2012 R2 Hyper-V
Configuration management comes to Windows
Desired state-configuration-ravikanth-august-2013-vtc india
Power shell saturday ravikanth
PowerShell 3.0 workflows

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
A Presentation on Artificial Intelligence
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
Electronic commerce courselecture one. Pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
MYSQL Presentation for SQL database connectivity
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Assigned Numbers - 2025 - Bluetooth® Document
Dropbox Q2 2025 Financial Results & Investor Presentation
A Presentation on Artificial Intelligence
A comparative analysis of optical character recognition models for extracting...
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars

PowerShell in the enterprise - TechED India 2011

  • 1. PowerShell in the EnterpriseBest Practices for adopting PowerShell as the automation platform
  • 2. About MeWork at Dell Inc.A Windows PowerShell MVPAuthor of:eGuide: A layman’s guide to PowerShell 2.0 remotingeGuide: WMI Query Language via PowerShellSharePoint 2010 PowerShell cheat sheet (for Quest)Automation is my passion
  • 3. AgendaIntroductionChallengesDeploying & Securing PowerShellDeveloping & Validating ScriptsTools for the jobQ & A
  • 5. IntroductionWindows PowerShell?Microsoft Common Engineering Criteria*..not just Microsoft anymore* http://www.microsoft.com/cec/en/us/cec-overview.aspx#man-windows
  • 6. ChallengesProperly manage PowerShellSecure the IT environmentMake automation effective
  • 7. Deploying PowerShellAvailable on Windows Server 2008 R2 and Windows 7, by defaultAvailable as an update (KB968929) for down level operating systems.Windows UpdateStandalone install
  • 8. Securing PowerShellWhat is script execution policy?Types of Execution PolicyRestrictedAllSignedRemoteSignedUnrestrictedByPassSigning scripts
  • 10. Developing ScriptsStart with the shellThink Objects, not textImplement scripting standardsLook for code optimizationsInclude script documentationInclude debug or verbose information
  • 11. DEMODeveloping ScriptsObject based shell and scripting standards
  • 12. Developing ScriptsDon’t re-invent the wheelPoshCode.OrgPowershellcommunity.org#PowerShellTechnet Scripts CenterForums
  • 13. Validating ScriptsValidate in a non-production environmentScript functionalityDesired output
  • 14. Tools for the jobSeveral script editorsWindows PowerShell ISEPowerGUI Script EditorIdera PowerShellPlusDevFarm PowerSEVisual Studio for developing PowerShell ScriptsPowerGUI VSXDevelop Forms & WPF GUI
  • 15. DEMOTools for the jobScript editors and Visual Studio
  • 16. SummaryWindows PowerShell is the futureof datacenter automationBest practices and recommendations make your environment effectiveand securePowerShell community is growingand eager to help you
  • 17. Thank YouEmail: Ravikanth@Ravichaganti.comBlog: http://www.ravichaganti.com/blogTwitter: http://www.twitter.com/ravikanth
  • 18. © 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.

Editor's Notes

  • #4: In this session, we will look at what is PowerShell (very briefly) and then move onto why PowerShell is an important skillset for any IT Professional out there. We shall then look at the challenges in adopting PowerShell as the automation platform and see some of the best practices and recommendations to overcome those challenges. Finally, we shall look at some of the tools for the job and how each tool solves a specific problem.Stop me any time you have a question. But, remember, this is not a PowerShell fundamentals session. So, if you have any of those questions, I prefer taking them offline. With that note, let us get started.
  • #5: I am giving away 2 PowerGUI Pro Licenses. Thanks to Quest software for that.Also, a Windows PowerShell 2.0 best practices book by Ed Wilson, the Scripting Guy.
  • #6: How many of you are system administrators?How many of you know what is PowerShell?How many of you know have “really” used PowerShell in your day to day work?PowerShell is the command-line shell and the scripting language from Microsoft. It was released in 2007 along with Windows Vista and Longhorn. PowerShell is currently in version 2. Microsoft is really putting lot of effort in making PowerShell as “THE” management interface for various MS products. In fact, MS has a Common Engineering Criteria program which is about a set of engineering requirements every MS product should comply with. If you look up the web site and go to manageability section, you would find that “Windows PowerShell is the Microsoft standard for automation”. And, then, you can also a find a list of all MS products that comply or don’t comply with this. Go to Score Cards on the same page, click by technical area, and select Windows PowerShell Scripting and click on product compliance. The ones in green are having full compatibility and support for Windows PowerShell Scripting.Now, we understand that MS is really putting lot of effort in pushing windows PowerShell as the automation platform. Now, that said, Microsoft isn’t alone. There are several other companies and partners building PowerShell support into their products, building Products for PowerShell itself, and making the whole IT automation even more easier. Question: Do you know any other companies with PowerShell support in their products?There are several hardware vendors adopting PowerShell as their management interface. For example, Dell has PowerShell cmdlets to manage their EqualLogic and Compellent storageNetApp released Data ONTAP PowerShell tool kit for managing their storageIntel has vPro cmdlets to manage system hardware and also, HP for their blade system management. These are just a few examples. We also have VMWare, RedHat, and others building PowerShell support into their products for management.So, as an IT pro, PowerShell is a necessary skill set going forward. If you have not started using PowerShell yet, this is the right time. I am sure having PowerShell in your CV adds tremendous value. Now, with all these companies along with MS pushing PowerShell so much, the IT administrators in the data center face a few challenges.
  • #7: Properly Manage PowerShellHow do you manage PowerShell in the data center. It is a product. Although, it is enabled by default Server 2008 R2 and Windows 7, not all data centers would have come to the recent OS yet. So, how do you deploy and update PowerShell?If you are going to deploy Windows PowerShell across your enterprise, you should review the best practices described below. These are especially recommended if several administrators will be using PowerShell scripts to manage production assets. Adhering to the best practices will ensure you get the most from your PowerShell investment in a secure and efficient manner.Securing PowerShellWhenever we think about scripts, the first thing that comes to my mind is security. What if the scripting platform itself is compromised? What if someone runs a rouge script?Tell you a story here: I was a system administrator at the beginning of my career. I managed a few hundred desktops and a few Windows & Unix servers. Early 2001 was when I started my career. So, I was actually managing Windows 95/98 and Windows 2000 desktops. If any of you are as old as I am, you may remember Anna Kournikova & LoveBugviruses. These were VBScripts spreading through email. So, when a user double-clicked on the attachment, scripting engine used to run the file and it sent emails to all people in the address book. This was possible because there were no restrictions on who can run those scripts in general and how. That was a major challenge. Although, we could filter the scripts at exchange, there was always a set of people who were blindly clicking the attachments they received through their personal emails, etc. The other workaround which we used was to change the default handler for .vbs files. We used Group Policy to change that to .txt file and whenever someone double-clicked on the .vbs file, it opened up in Notepad. But, that is not real protection. Ideally, the real restriction should have been at the scripting engine level. This is what PowerShell provides and we shall see how to use that.Of course, another challenge would be: How do we make automation effective?This is another big challenge. Automation isn’t just about writing scripts. It is also about how well those scripts were written, how easy those scripts are for someone to read and understand, and what tools do you use to develop these scripts, etc. You may use notepad for writing scripts but Is that the right thing to do? And, you may have someone in your org who just downloaded or written a cool script for doing some task against your production servers. Now, do you know if that script is optimized for speed, written with all coding standards in place, etc? We shall see some scripting standards and tools for the job towards the end of this session.
  • #9: So, I said PowerShell engine itself supports restricting script execution. This is achieved using called script execution policies. These policies are the conditions under which PowerShell runs scripts. By default, PowerShell does not run any scripts. It allows only command execution. So, when you, as an administrator, not changed any default PowerShell settings, your end users, or any programs won’t be able to execute any scripts. Of course, one thing to remember is: an execution policy does not prevent user from running each command within a script. These execution policy settings are stored in the registry. (HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell)You can use Get-ExecutionPolicy cmdlet to see the current execution policy setting and use Set-ExecutionPolicy to change it.<Demo> There are 5 types of execution policies. <Demo> Get and Set Execution Policies.Users can change the execution policy using Set-ExecutionPolicy cmdlet. However, this requires administrative privileges. This essentially means that you have to be at the elevated command prompt. This is another layer of security. You cannot change script execution policy unless you have the admin privileges.<Demo> Script SigningI will briefly touch upon script signing here and show an actual demo to you. A few execution policies such as AllSigned and remoteSigned require that the PowerShell scripts you want to run be digitally signed.Any script that will be executed in a production environment, especially on mission-critical servers, shouldbe signed with a code signing certificate trusted by your domain. You can certainly acquire a code signingcertificate from a third-party vendor, but it doesn‘t take much to set up the free Certificate Services fromMicrosoft and issue your own. Since the certificates are essentially issued by your domain, they areautomatically trusted by all member servers and desktops.A digitally signed script is critical because it ensures that the script has not been modified since it was lastsigned. You can use the Get-AuthenticodeSignaturecmdlet to verify signature integrity.<You can also use Group Policy to Set Execution Policy>#Can be set via Group Policy#Precedence is as follows:#Group Policy: Computer Configuration#Group Policy: User Configuration#Execution Policy: Process (or PowerShell.exe -ExecutionPolicy)#Execution Policy: CurrentUser#Execution Policy: LocalMachine
  • #11: Always start with the Shell. It is not always a good idea to begin trying to write a few hundred lines of PowerShell script. Instead, start with the shell. Anything you can run at the shell can be into a script. First, verify how the command runs in the shell. Once you have the expression or command working, you can put it into a script. Also, to start with, avoid writing complex expressions. Start with a simple expression and build on it as you see it working. If you write complex expressions and it results in an error, it becomes quite tough to debug.PowerShell is an object based shell. Which means you pass around objects when dealing with PowerShell commands and scripts. This is a change in mindset from the usual Shell experience where everything is TEXT. When scripting in PowerShell, It is always a good idea to receive and return Objects. This way you can use the built-in cmdlets to manipulate the objects and work with them.<DEMO> Object based shellCoding StandardsCode OptimizationsWhen writing scripts, you should always look for code optimizations. While it is important to achieve the goal of automation, it is also very important to optimize the code for speed of execution and resource utilization. For example, you write a script that works on, let us say a few 100 servers, but takes ages to complete and eats up all the memory you have on the management station, there is no use. These kind of long running scripts have to be always optimized. And, there are several ways to achieve this. You can look at how you can create faster looping constructs and how you can limit the number of properties you retrieve, etc. Let us a couple of demos to understand this.<DEMO Coding standards>
  • #13: PowerShell has been around for a few years now and the PowerShell community is very strong. There are many experts who respond to questions on twitter, facebook, Stackoverflow and several other forums every day. And, this is not just about PowerShell MVPs. There are also other MVPs and PowerShell experts who are eager to help you. In fact, last morning I wanted to write something to automate my 2+TB SQL TB restore. I have 11 such databases to restore for testing purpose on a regular basis. I know someone must have already solved such a problem. So, I pinged a friend of mine who happens to be a SQL MVP and he pointed me to a PowerShell script that uses SMO and PowerShell for database restores. See, I solved 50% of my problem just asking a question. Now, all I had to do was wrap it up in another simple PowerShell Script to do the DB restores in background and wait for all the restores to complete. Simple!This simply means, you may have a great idea for a script but someone might have already thought about it. There is poshcode.org and technet script center for code sharing. These sites a few thousand community submissions. While you may or may not find the exact script you are looking for but these sites can be a very good starting point.
  • #14: It should go without saying: any PowerShell script or function—whether developed internally or downloaded from a source like PoshCode.org—must be tested thoroughly in a non-production environment.Be sure to test not only how the script runs successfully, but also how it fails. What happens when you pass it invalid parameters or if a required resource is unavailable? What can you do to make the script or function fail? It is critical that you understand how the script handles problems. This is especially true of internally developed scripts. You should be able to take this information and revise your script to make itas robust as possible.You should have peer code reviews, unit testing, pilot testing, as well as management sign-off and approval. Administrative scripting does not have to be ad hoc or throwaway; in fact, it‘s just the opposite, scripting should be closely managed. PowerShell can bring a server or network down with only a few lines of code, assuming proper permissions. You should not have PowerShell scripts running in your environment that you don‘t understand, trust and approve.