Windows Server 2016 Automation with PowerShell Cookbook - Second Edition
eBook - ePub

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

  1. 660 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

Book details
Book preview
Table of contents
Citations

About This Book

Over 100 recipes to help you leverage PowerShell to automate Windows Server 2016 manual tasksAbout This Book• Automate Windows server tasks with the powerful features of the PowerShell Language• Master new features such as DevOps, containers, and Nano servers, and speed up their performance using PowerShell• Improve PowerShell's usability, and control and manage Windows-based environments by working through inviting recipesWho This Book Is ForIf you are a systems administrator, engineer, or an architect working with Windows Server 2016 and want to automate tasks with PowerShell, then this book is for you. A basic knowledge of PowerShell is expected.What You Will Learn• Streamline routine administration processes• Improve the performance and storage of your Windows server with enhanced large-scale PowerShell scripts• Use DSC to leverage Windows server features• Generate automatic reports that highlight unexpected changes in your environment• Monitor performance and report on system utilization using detailed graphs and analysis• Create and manage a reliable and redundant Hyper-V environment• Manage your enterprise's patch level• Utilize multiple tools and protocols to manage your environmentIn DetailThis book showcases several ways that Windows administrators can use to automate and streamline their job. You'll start with the PowerShell and Windows Server fundamentals, where you'll become well versed with PowerShell and Windows Server features.In the next module, Core Windows Server 2016, you'll implement Nano Server, manage Windows updates, and implement troubleshooting and server inventories. You'll then move on to the Networking module, where you'll manage Windows network services and network shares.The last module covers Azure and DSC, where you will use Azure on PowerShell and DSC to easily maintain Windows servers.Style and approachThis is a practical guide packed with attractive recipes to help you effectively use PowerShell to accelerate your daily administrative tasks with Windows server.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Windows Server 2016 Automation with PowerShell Cookbook - Second Edition by Thomas Lee in PDF and/or ePUB format, as well as other popular books in Computer Science & Operating Systems. We have over one million books available in our catalogue for you to explore.

Information

Year
2017
ISBN
9781787126404
Edition
2

Managing Hyper-V

In this chapter, we cover the following recipes:
  • Installing and configuring Hyper-V feature
  • Using Windows PowerShell Direct
  • Securing Hyper-V host
  • Creating a virtual machine
  • Configuring VM hardware
  • Configuring Hyper-V networking
  • Implementing nested Hyper-V
  • Managing VM state
  • Configuring VM and storage movement
  • Configuring VM replication
  • Managing VM checkpoints
  • Monitoring Hyper-V utilization and performance
  • Creating a Hyper-V health report

Introduction

Hyper-V is Microsoft's virtual machine hypervisor. Both Windows Server 2016 and Windows 10 include Hyper-V as an option you can install. The Hyper-V feature is included in all versions of Windows Server 2016, as well as in the Enterprise, Professional, and Education editions of Windows 10. Nested Hyper-V, the ability to run Hyper-V inside a Hyper-V VM, is available in both Windows 10 Anniversary Update and Windows Server 2016. Additionally, Microsoft has made the Microsoft Hyper-V Server available as a free version of the Hyper-V hypervisor. The Hyper-V Server runs virtual machines with no GUI. You configure and manage remotely.
Hyper-V was first released with Server 2008. Successive versions of Windows brought improvements in features, hardware support, and scalability. The first version did not include PowerShell cmdlet support, but that was rectified in later releases. With Server 2016 there is good PowerShell coverage. This chapter focuses solely on Hyper-V inside Windows Server 2016 although you can manage Hyper-V Server using the tools used in this chapter's recipes.
Hyper-V's management tools enable you to configure and manage both the Hyper-V service and configure and manage virtual machines and the resources they utilize. This chapter starts with installing and configuring the Hyper-V Server role. Later in the chapter, you create and manage virtual machines. The chapter ends with looking at high availability for Hyper-V Servers and Hyper-V VMs, host resource protection, and PowerShell Direct.

Installing and configuring Hyper-V feature

To install Hyper-V on Windows Server 2016, you install the Hyper-V feature. In this recipe, you do the set up remotely from a client machine using the Hyper-V cmdlets and PowerShell's remoting capabilities.

Getting ready

For this recipe, you need to have the host computers on which you install Hyper-V. This recipe uses two servers, HV1 and HV2. Each server is a member of the domain on which you have added no additional services. As an alternative to having two systems running, you could use embedded Hyper-V and create the two VMs inside a third.
To demonstrate remote configuration, you perform this recipe from a third computer, CL1 running Windows 10 (Anniversary Update). This recipe makes use of a second hard disk, an H: drive on the HV1 and HV2 systems that you use to store Hyper-V VMs and virtual disks.
You need the Hyper-V tools on CL1—add them using the Enable-WindowsOptionalFeature and use the -Online switch, as follows:
# Add windows optional feature for CL1 Enable-WindowsOptionalFeature ` -FeatureName Microsoft-Hyper-V-All ` -Online -NoRestart Restart-Computer -Computername CL1 -Force 
If you are using Windows 10 to test these recipes, you can install Hyper-V features assuming you have the Professional, Enterprise, or Educational editions. If you install Hyper-V on either Windows 10 or Server 2016, you need to reboot the host computer before proceeding.

How to do it...

This recipe shows how to install Hyper-V:
  1. From CL1, install the Hyper-V feature on HV1, HV2:
 $Sb = {
Install-WindowsFeature -Name Hyper-V `
-IncludeManagementTools }
Invoke-Command -ComputerName HV1, HV2 `
-ScriptBlock $Sb
  1. Reboot the servers to complete the installation:
 Restart-Computer -ComputerName HV1, HV2 -Force `
-Wait -For -PowerShell
  1. Create and set the location for VMs and VHDs on HV1 and HV2, then view results:
 $Sb = {
New-Item -Path H:\Vm -ItemType Directory -Force |
Out-Null
New-Item -Path H:\Vm\Vhds -ItemType Directory -Force |
Out-Null
New-Item -Path H:\Vm\VMs -ItemType Directory -force |
Out-Null
Get-ChildItem -Path H:\Vm }
Invoke-Command -ComputerName HV1, HV2 -ScriptBlock $Sb
  1. Set default paths for Hyper-V VM hard disks and VM configuration information:
 Set-VMHost -ComputerName HV1,HV2 `
-VirtualHardDiskPath 'H:\Vm\Vhds'
Set-VMHost -ComputerName HV1,HV2 `
-VirtualMachinePath 'H:\Vm\VMs'
  1. Setup NUMA spanning:
 Set-VMHost -ComputerName HV1,HV2 -NumaSpanningEnabled $true
  1. Set up EnhancedSessionMode:
 Set-VMHost -ComputerName HV1,HV2 `
-EnableEnhancedSessionMode $true
  1. Setup host resource metering on HV1, HV2:
 $RMInterval = New-TimeSpan -Hours 0 -Minutes 15
Set-VMHost -CimSession HV1, HV2 -ResourceMeteringSaveInterval
$RMInterval
  1. Review key VMHost settings:
 Get-VMHost -ComputerName HV1, HV2 | 
Format-List -Property Name, MemoryCapacity,
Virtu...

Table of contents

  1. Title Page
  2. Copyright
  3. Credits
  4. About the Author
  5. Acknowledgment
  6. About the Reviewer
  7. www.PacktPub.com
  8. Customer Feedback
  9. Preface
  10. What's New in PowerShell and Windows Server
  11. Implementing Nano Server
  12. Managing Windows Updates
  13. Managing Printers
  14. Managing Server Backup
  15. Managing Performance
  16. Troubleshooting Windows Server 2016
  17. Managing Windows Networking Services
  18. Managing Network Shares
  19. Managing Internet Information Server
  20. Managing Hyper-V
  21. Managing Azure
  22. Using Desired State Configuration