Time-Saving PowerShell Solutions for the Busy Admin

Time-Saving PowerShell Solutions for the Busy Admin

By Rod Trent

Brought to you by Windows IT Pro

sponsored by

Sponsored by NetApp

NetApp

Tech Advisor ? Windows IT Pro | p. 2

Contents

Time-Saving PowerShell Solutions for the Busy Admin

Simple Hyper-V Virtual Machine Management Using PowerShell

PowerShell One-liner:

Creating a new VM 10

Quickly Finding the IP Address

for Hostname and Vice Versas4 Removing an Existing VM 10

Run the Access Control App

Starting an Existing VM 10

to Configure Windows Remote

Management with PowerShell5 Stop a Running VM 10

Pausing PowerShell Script

Pause a Running VM 11

Execution6

Restart a Paused VM 11

PowerShell One-Liner:

Getting Local Environment

Save and Hibernate a VM 11

Variables6

Changing the Name of a VM 11

PowerShell Tip:

Outputting Information

Moving a VM to another

to HTML8 Hyper-V Server 11

Forcing PowerShell to Wait

Export and Importing

for a Process to Complete9 a Working VM 11

Brought to you by Windows IT Pro

Sponsored by NetApp

Rod Trent is the IT Community Manager for Windows IT Pro. He is a leading expert on Microsoft System Center technologies and has more than 25 years of IT experience, with over 20 years dedicated to System Center. Rod has written many books, thousands of articles, and speaks at various conferences and user groups. His professional focus is evangelizing technical community on the web and in person. Rod was a Microsoft MVP for 10 years and is a charter member of the Dell TechCenter Rockstar program.

Tech Advisor ? Windows IT Pro | p. 3

Introduction

PowerShell is the scripting language now embedded into every Microsoft business software product, allowing seemingly simple commands to expose powerful, automated solutions. For many Microsoft products, PowerShell is required to control, extend and manage various processes. PowerShell can be used to initiate simple tasks and inquiries and can also be strung together to automate more complex sets of operations, for instance within a private cloud environment. In the past, various scripting languages required months of study to do simple things, but PowerShell has changed all of that. Learning PowerShell seems extremely daunting to some, but once study starts, users find the simplicity to be refreshing.

PowerShell is a hugely powerful (pun intended) scripting language and Microsoft has invested a lot of resources and support behind making it an integrated part of every piece of the company's software offerings. It's really nothing to be afraid of and those that start down the path to learning find it simple and easy to understand. And, as the education progresses, it gets easier and easier.

This guide is intended to help IT professionals build a relationship with PowerShell, and aid in understanding how powerful simple, one-line commands can be.

Brought to you by Windows IT Pro

Sponsored by NetApp

NetApp creates innovative storage and data management solutions that deliver outstanding cost efficiency and accelerate business breakthroughs. Our deep integration with Microsoft products and technologies has been recognized and awarded by Microsoft when NetApp was named their 2012 Private Cloud Partner of the Year and 2013 Server Platform Partner of the Year. NetApp provides a comprehensive PowerShell Module with over 1,400 PowerShell cmdlets in our Data ONTAP PowerShell Toolkit for everything from simple task initiation to complex private cloud, back-up, and disaster recovery automation. Learn more at NetApp's PowerShell Toolkit Community

Sponsored by NetApp

Tech Advisor ? Windows IT Pro | p. 4

Time-Saving PowerShell Solutions for the Busy Admin

PowerShell One-liner: Quickly Finding the IP Address for Hostname and Vice Versa

When you're curious what the IP Address of a specific hostname might be, you can use a quick PowerShell one-liner to retrieve the information.

Run the following scriptlet in the Windows PowerShell window and insert your own hostname for which you're wanting to locate the IP Address.

[.Dns]::GetHostAddresses("")

Output:

Alternatively, if someone gives you an IP Address and you'd like to determine the hostname to which it is associated, run the following scriptlet:

[.Dns]::GetHostbyAddress("206.72.117.68")

Output:

Brought to you by Windows IT Pro

Sponsored by NetApp

Tech Advisor ? Windows IT Pro | p. 5

Run the Access Control App to Configure Windows Remote Management with PowerShell

PowerShell is powerful, for sure. But, with that power comes great, uh, responsibility. Part of that responsibility is ensuring commands can be run remotely, and by the right people. If you need to adjust the Access Control List for utilizing PowerShell commands on remote computers, you'll first need to know how to open the UI for managing and modifying the ACLs.

Do this:

1. As an Administrator, run the following at a PowerShell prompt:

Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell ?Force

2. You'll be prompted to ensure that the WinRM service is running. Answer "Y" (Yes) to start the Windows service.

3.Once the service is started the Access Control applet will run, allowing you to make modifications:

We'll go deeper into PowerShell remoting in future articles, but, this will get you started down the path and give you another "cool thing" to know.

Brought to you by Windows IT Pro

Sponsored by NetApp

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download