Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Windows Server 2012 R2 Administrator Cookbook

You're reading from   Windows Server 2012 R2 Administrator Cookbook Over 80 hands-on recipes to effectively administer and manage your Windows Server 2012 R2 infrastructure in enterprise environments

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781784393076
Length 310 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Jordan Krause Jordan Krause
Author Profile Icon Jordan Krause
Jordan Krause
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Learning the Interface FREE CHAPTER 2. Core Infrastructure Tasks 3. Security and Networking 4. Working with Certificates 5. Internet Information Services 6. Remote Access 7. Remote Desktop Services 8. Monitoring and Backup 9. Group Policy 10. File Services and Data Control Index

Using PowerShell to accomplish any function in Windows Server

An incredibly powerful tool in Windows Server 2012 R2 is PowerShell. Think of PowerShell like a command prompt on steroids. It is a command-line interface from which you can manipulate almost anything inside Windows that you may care to. Better yet, any task that you may wish to accomplish can be scripted out in PowerShell and saved off as a .ps1 script file, so that you can automate large tasks and schedule them for later, or at regular intervals. In this recipe, let's open up PowerShell and run some sample commands and tasks just to get a quick feel for the interface. In a later chapter of the book, we will do some more specific tasks with PowerShell to go even deeper into the technology.

Getting ready

To start using PowerShell, all you need is a server with Windows Server 2012 R2 installed. PowerShell is installed and enabled by default.

How to do it...

To get a feel of using PowerShell, perform the following steps:

  1. Right-click on your blue PowerShell icon and make sure to open PowerShell as administrator by clicking on Run as administrator. PowerShell is very powerful, but only if you have admin rights in the session.
    How to do it...
  2. Test out some commands that you are familiar with from using the command prompt, such as dir and cls. Since you are able to make use of these familiar commands, PowerShell can really be your one and only command-line interface if you choose.
  3. Now let's try some of the PowerShell secret sauce, one of its cmdlets. These are special commands that are built into Windows and allow us to do all kinds of information gathering, as well as manipulation of server components. Let's start by pulling some data. Maybe take a look at what IP addresses are on the system with Get-NetIPAddress.
    How to do it...
  4. The previous command probably gave you a lot more information than you needed, since most companies don't make use of IPv6 inside their network yet. Let's whittle this information down to the IPv4 specific info that you are most likely interested in. Enter Get-NetIPAddress –AddressFamily IPv4 to attain it.
    How to do it...

How it works...

PowerShell has so many commands and cmdlets, we just wanted to get a feel for launching the program and pulling some data with this particular recipe. There are countless Get commands to query information from the server, and as you have seen those cmdlets have various parameters that can be appended to the cmdlets to pull more specific data to meet your needs. To make things even better, there are not only Get cmdlets, but also Set cmdlets, which will allow us to make use of the PowerShell prompt to configure many aspects of the configuration on our server, as well as remote servers. We will dive further into PowerShell in a later chapter.

You have been reading a chapter from
Windows Server 2012 R2 Administrator Cookbook
Published in: Jan 2015
Publisher:
ISBN-13: 9781784393076
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime