powershell training guide

14
SDO - Architecture Powershell Training Guide Table of Contents 1 Server Management with Powershell............................................2 1.1 Why Should I Learn Powershell?..........................................2 1.2 Requirements for Constitent Mangement Experience in Data Center.........5 1.2.1......................Powershell 3.0 and Windows Management Framework 3.0 5 1.2.2........................Bank of Windows Server 2012 R2 Management Servers 5 2 Training Resources for Powershell and Windows Server 2012....................7 2.1 WARNING................................................................. 7 2.2 Getting Started with Powershell 3.0 Jump Start – Excellent MVA Course - Free.................................................................... 7 2.3 Join PowerShell.com and PowerShell.org..................................8 2.4 Windows Server 2012: Management & Automation............................8 2.5 Commercial Courses...................................................... 9 2.6 Server 2012 Folder on Architecture MeeBee Site..........................9 2.7 Azure Lab Environment.................................................. 10 2.8 Obtain Free Evaluation Version of Windows Server 2012..................10 3 Required Team Involvement...................................................11 3.1 Create Use Cases....................................................... 11 3.2 SDO PowerShell Cheat Sheet............................................. 11 3.3 Look Beyond Current Capabilities.......................................11 BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 1

Upload: kizarnie3920

Post on 27-Dec-2015

27 views

Category:

Documents


5 download

DESCRIPTION

Microsoft Powershell

TRANSCRIPT

Page 1: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

Table of Contents

1 Server Management with Powershell..............................................................................................................................................2

1.1 Why Should I Learn Powershell?............................................................................................................................................2

1.2 Requirements for Constitent Mangement Experience in Data Center....................................................................................5

1.2.1 Powershell 3.0 and Windows Management Framework 3.0..................................................................................................5

1.2.2 Bank of Windows Server 2012 R2 Management Servers......................................................................................................5

2 Training Resources for Powershell and Windows Server 2012....................................................................................................7

2.1 WARNING..............................................................................................................................................................................7

2.2 Getting Started with Powershell 3.0 Jump Start – Excellent MVA Course - Free..................................................................7

2.3 Join PowerShell.com and PowerShell.org..............................................................................................................................8

2.4 Windows Server 2012: Management & Automation...............................................................................................................8

2.5 Commercial Courses..............................................................................................................................................................9

2.6 Server 2012 Folder on Architecture MeeBee Site..................................................................................................................9

2.7 Azure Lab Environment........................................................................................................................................................10

2.8 Obtain Free Evaluation Version of Windows Server 2012...................................................................................................10

3 Required Team Involvement...........................................................................................................................................................11

3.1 Create Use Cases................................................................................................................................................................11

3.2 SDO PowerShell Cheat Sheet..............................................................................................................................................11

3.3 Look Beyond Current Capabilities........................................................................................................................................11

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 1

Page 2: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

1 Server Management with Powershell

Microsoft Windows operating systems have supported a wide range of command line tools and scripting tools over the years. Even though server administration could be accomplished with a combination of command line tools and scripting technologies, Windows lacked a consistent automation framework for administrative tasks. Powershell is the answer to that need. With the release of Windows Server 2012, Microsoft has added a wide array of command-lets to support automation for all facets of the OS. In addition, Microsoft product teams for server products are required to provide command-lets to support the automation of their product. Thus, the ActiveDirectory team ships command-lets that help automate Activedirectory. The SystemCenter team ships command-lets that help automate SystemCenter, etc.

The purpose of this document is to provide a starting point for the training required by SDO on the ProdOps, IOPS, and NOCC teams in order for us to be able to support Windows Server 2012. In the training section, it provides a list of free online courses that administrators should complete in order to become proficient at managing servers using Powershell.

1.1 Why Should I Learn Powershell?

The following excerpt was taken from Learn Windows Powershell 3 in a Month of Lunches, a book that I highly recommend. It was written by Don Jones and Jeffrey D. Hicks.

“Microsoft’s goal for Windows Powershell is to build 100% of a product’s administrative functionality in the shell. Microsoft continues to build GUI consoles, but those consoles execute Powershell commands behind the scenes. That approach forces the company to make sure that every possible thing you can do with the product is accessible through the shell. If you need to automate a repetitive task or create a process that the GUI does not enable well, you can drop into the shell and take full control for yourself.”

It is difficutl to increase productivity through GUI work. If it takes 3 minutes to add a user by hand to AD, it will take 60 minutes to add 20. It it takes 5 minutes to collect log files from two separate web servers, zip them up, and mail them to PD, it will take 5 minutes every time. Powershell provides an opportunity to be more productive in a consistent manner. There no longer is a need to resort to different command line tools and scripting technologies for separate tasks. More and more products will support automation through PowerShell in the future, beyond the OS. SystemCenter is one of them. Thus, it is an investment worth making.

With the roll-out of Windows Server 2012, the core installation will be used wherever possible in SDO. This includes both Web and SQL servers. No GUI components will be installed on servers. This reduces the number of patches that have to be applied by a significant margin. With a core install, administrators connecting to servers will see but a command line as illustrated in the screen shot below. Thus, administrators will need to know the Powershell equivalent of tasks that they used to perform by using a GUI-based tool.

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 2

Page 3: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

It is best pratice to not rely on remote desktop connections for server administration. The plan is to switch to a model that relies on a bank of management servers running on 2012. These servers will have the GUI components installed. While it will be possible to use GUI-based tools to connect to remote machines, it is often more efficient to simply drop to a command line on the management box and execute Powershell commands against the servers remotely. Powershell uses a remoting framework that is easier to configure in terms of firewall rules than traditional DCOM/RDP calls. Microsoft has also invested heavily in the security model surrounding their PowerShell remoting model.

The online Microsoft guide to managing Windows Server 2012 core deployments can be found here: http://technet.microsoft.com/en-us/library/cc753802%28v=ws.10%29.aspx

The screenshot below illustrates the server manager GUI that is installed with Windows Server 2012. Using this interface, it is easy to manage other systems from a central manager server by using Powershell or GUI-based tools.

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 3

Page 4: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

By selecting the Windows PowerShell context menu item for a server, a remote PowerShell session will be opened on the local management server. It allows the administrator to run PowerShell tasks against the remote server from a central location, as illustrated in the screenshot below. PowerShell will put the FQDN of the server on the command line to make it easy for administrators to see what server they are about to perform a task on.

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 4

Page 5: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

In addition, PowerShell provides great support for fan-out remoting. Many command-lets take a parameter called –computerName that allows the administrator to specify a collection of computers that the command-let should be executed against.

1.2 Requirements for Constitent Mangement Experience in Data Center

In order for us to move to a remote management framework driven by Powershell and Windows Server 2012, the following requirements will have to be met:

1.2.1 Powershell 3.0 and Windows Management Framework 3.0Powershell Version 3.0 should be used across the board to manage Windows Server 2012 as well as servers running on older operating systems. In order to obtain the full benefits of the additional capabilities added to Powershell 3.0 and to the Windows Server 2012 automation stack, it will be necessary to install Windows Management Framework 3.0 on servers running Windows Server 2008 R2 Sp1. The framework can be downloaded from the following location:

Windows Management Framework 3.0 Download

Versions for Windows 7, Window Server 2008 SP2, and Windows Servers 2008 R2 SP1 are available.

The download is also available in the BO3 data center software library at the following location:

\\bbhcifs01\softwaredepot\Microsoft\Windows Management Framework 3.0

Installing the Windows Management Framework will require a reboot on the server and will have to be done as part of patching or during a maintenance window. Do not install the framework without going through an RFC. The rollout will have to be coordinated with the IOPS team.

Installing the 3.0 Management framework on 2008 R2 SP1 Servers will add the following components to the server:

Windows PowerShell 3.0 Windows Remote Management (WinRM) 3.0 Windows Management Instrumentation (WMI) Management OData IIS Extension Server Manager CIM Provider

The CIM provider enables administrators to use Server Manager in Windows Server 2012 to manage computers running Windows Server 2008 R2 SP1 and Windows Server 2008 SP2.

1.2.2 Bank of Windows Server 2012 R2 Management ServersIn order to manage both Windows Server 2012 and Windows Server 2008 R2 servers remotely, we will need to create a bank of management servers that run on Windows Server 2012. The Production Operations team

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 5

Page 6: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

currenly has serveral management servers that are used for SiteManager. We will either have to stand up separate management servers or replace the existing ones with Windows Server 2012. Older operating systems, such as Windows Server 2003, do not lend themselves to remote management to the same degree and the traditional method of establishing an RDP connection to the server has to be used.

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 6

Page 7: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

2 Training Resources for Powershell and Windows Server 2012

There are a vast number of courses and training materials available for Powershell. Some of them are free, others are commercial. A lot of the training resources and commercial courses gravitate towards a programming based approach and focus on writing lengthy scripts. Knowing how to use variables, conditionals, and other programming concepts can be helpful. However, a lot of administrators simply need to rely on one-line command-lets to accomplish tasks. Most of the operational engineers will not write scripts that are hundreds of lines long.

I found one course at the Microsoft Virtual Academy that I highly recommend, as it is geared to fill this need. It consists of 10 sections and will require about 10 hours to complete. A Microsoft Live account is required in order to complete the course and take the self assessment. If you do not have an account, visit the following page to create one: https://login.live.com. There is a Sign up now link at the bottom right corner of the login page.

2.1 WARNING

PowerShell is a powerfull tool. You can accomplish very complex tasks very quickly. You can also do a lot of damage very quickly. When practising, practise on your desktop or in the training environment we created in Azure. DO NOT practise in the data center environment.

In addition, educate yourself about the meaning of the –WhatIf and –confirm parameters. These are safety nets you can use if you are not sure what your script will do or if you want the ability to cancel.

2.2 Getting Started with Powershell 3.0 Jump Start – Excellent MVA Course - Free

This course is designed to teach IT professionals, admins, and help desk persons how to use PowerShell to improve management capabilities, automate redundant tasks, and manage the environment in scale. It is taught by Jeffrey Snover, the inventor of PowerShell, and Jason Helmick, Senior Technologist at Concentrated Technology. The course is available here:

http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start#fbid=tV6714MxWG2

The screen shot below shows which modules are discussed. You can earn 200 points in the MVA for taking the course and completing the self-assessment. It is critical to try to apply the material learned in the course and experiment with it. The self-assessment is a multiple-choice test that mainly verifies that you have followed along through the presentation.

I completed the course sequence myself. Even though I had been using PowerShell for some time, albeit sporadically, I learned several new things and found it time well spent. Best of all, it is free.

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 7

Page 8: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

2.3 Join PowerShell.com and PowerShell.org

Both of these web sites provide excellent script libraries, forums, web casts and free eBooks. You will need to create an account before being able to download the materials.

http://powershell.com/cshttp://powershell.org/wp

2.4 Windows Server 2012: Management & Automation

Make sure you take the introductory PowerShell course before taking this course. This is another course offered free of charge through Microsoft’s Virtual Academy that each administrator should complete to obtain a

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 8

Page 9: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

good understanding of the management capabilities that come with Windows Server 2012. The following modules are included:

http://www.microsoftvirtualacademy.com/training-courses/windows-server-2012-manageability-and-automation#fbid=tV6714MxWG2

2.5 Commercial Courses

Most IT training centers offer courses. A lot of them are geared to teach more advanced scripting concepts and take more of a software development approach. Most IT administrators will not end up writing lengthy PowerShell scripts. A course that focuses too much on the scripting aspect is probably not the best choice for administrators as their first exposure to PowerShell.

There is a series of books available in the Learn X in a Month of Lunches series. It includes Learn Windows PowerShell v3 in a Month of Lunches. The latter book is very good an contains a series of labs to work through. The web site http://morelunches.com provides a list of resources for each book and a complete set of self-paced video courses is available, along with several free YouTube posts. While it is up to each team/individual to pick the training material that works best for them, the Microsoft course along with some pratice will be sufficient in my opinion to obtain the skills necessary to master basic administration skills in Powershell.

2.6 Server 2012 Folder on Architecture MeeBee Site

There are several documents in this folder that have been written to discuss Server 2012 and Powershell. They are located at the following location: Server 2012 Folder on Enterprise Architecture Meebee Site

Windows Server 2012 OS Feature Overview

This PowerPoint presentation outlines some of the new features in Windows Server 2012 that are of interest to us. It lists those feature that we need to be able to support out of the box, along with other features that are of interest in the intermediate future and will require additional research and evaluation time.

Windows Server 2012 Setup

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 9

Page 10: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

This document contains detailed setup steps for Windows Server 2012 that were followed when provisioning the initial instances of Windows Server 2012 for the deployment of System Center. This document can be used as a starting point to develop a more detailed deployment standard. It also contains additional links to training materials.

VM-Windows 2012

This Excel spreadsheet is based on the check list that is / was used by the IOPS team to provison new 2008 servers. It contains PowerShell equivalents for some of the setup tasks that were performed during the provisioning of new servers. The goal is to have new servers provisioned in a compeltely automatic fashion without human intervention. This spreadsheet was intended to help administrators with the initial setup which was manual.

2.7 Azure Lab Environment

We have created a lab environment in Microsoft Azure consisting of two management servers, The following document explains how to connect to the environment:

http://meebee/sites/DCO/Enterprise%20Architecture/Shared%20Documents/Server2012/Windows%20Azure%20Test%20Lab.docx

If you have any questions about the lab, please email [email protected]

2.8 Obtain Free Evaluation Version of Windows Server 2012

You may download an evaluation version in ISO or VHD format. In order to try Windows Server 2012 *.VHD format, you must have the Hyper-V role enabled on your Windows 8 desktop / laptop. If you have a copy of VMWare Player or VMWare Work Station, you can run it on VMWare as well. It works in Workstation. I have not tried it on the player version. If you have VMWare, you are probably better off downloading the ISO version and going through the setup process rather than attaching the VHD file.

http://technet.microsoft.com/en-us/evalcenter/hh670538(v=msdn.10).aspx

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 10

Page 11: Powershell Training Guide

SDO - ArchitecturePowershell Training Guide

3 Required Team Involvement

The teams that stand to gain the most from mastering PowerShell are IOPS, ProdOps, and the NOCC. Each team will require training to enable their members to support Windows Server 2012 and beyond by using the 2012 management interface along with PowerShell.

3.1 Create Use Cases

One step that needs to be completed is gathering the use cases that currently require administrators to connect to a remote server and perform a management task. Once these use cases have been documented, we can collaborate on coming up with the equivalent PowerShell solution for the task, be it by using a native command-let that ships with PowerShell or a custom PowerShell script that wraps up functionality requiring several lines of code.

3.2 SDO PowerShell Cheat Sheet

The end goal of this effort will be to come up with an SDO cheat-sheet that clearly outlines how certain tasks should be completed at the PowerShell level in an efficient manner without the need to RDP into a server.

3.3 Look Beyond Current Capabilities

SystemCenter will provide additional management functionality tied to the monitoring tool in the form of tasks. That said, the Windows Server 2012 management console also provides rich functionality to manage servers that can be leveraged by certain teams. I can see the ProdOps team taking advantage of server groups in the server manager that are arranged around Infinity rigs for example. As you become familiar with the new capabilities, there is tremendous opportunity here to take automation to the next level by using a combination of Windows Server 2012, PowerShell, and SystemCenter. The key is to be familiar with what is available and start using it to see how it can help accomplish your daily tasks. Specifically, this involves managing IIS remotely.

BLACKBAUD PROPRIETARY AND CONFIDENTIAL INFORMATION 10/16/2013 I PAGE 11