PowerShell: A Comprehensive Guide to Windows PowerShell
By Sam Griffin
3.5/5
()
About this ebook
POWERSHELL
Are you looking for an easy way to simplify and automate administration of all your Microsoft products? You can't go wrong with Windows PowerShell, one of the most powerful scripting languages ever devised!
PowerShell makes it easy to retrieve data about your system se
Read more from Sam Griffin
Linux: A Comprehensive Guide to Linux Operating System and Command Line Rating: 0 out of 5 stars0 ratingsWindows 10: A Complete Guide to Using Windows 10 Rating: 0 out of 5 stars0 ratingsHacking: A Comprehensive Guide to Computer Hacking and Cybersecurity Rating: 0 out of 5 stars0 ratings
Related to PowerShell
Related ebooks
Mastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5Getting Started with PowerShell Rating: 0 out of 5 stars0 ratingsThe Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsPowerShell: A Beginner's Guide to Windows PowerShell Rating: 4 out of 5 stars4/520 Windows Tools Every SysAdmin Should Know Rating: 5 out of 5 stars5/5Getting Started With Powershell for Office 365 Rating: 0 out of 5 stars0 ratingsMastering PowerShell: Unleashing the Power of Automation: The IT Collection Rating: 5 out of 5 stars5/5PowerShell Troubleshooting Guide Rating: 0 out of 5 stars0 ratingsConfigMgr - An Administrator's Guide to Deploying Applications using PowerShell Rating: 5 out of 5 stars5/5Basics with Windows Powershell Rating: 0 out of 5 stars0 ratingsGoing Text: Mastering the Command Line Rating: 4 out of 5 stars4/5Microsoft System Center PowerShell Essentials Rating: 0 out of 5 stars0 ratingsWindows Batch File Programming Rating: 2 out of 5 stars2/5Active Directory with PowerShell Rating: 4 out of 5 stars4/5Learn Windows PowerShell in a Month of Lunches Rating: 0 out of 5 stars0 ratingsThe Windows Command Line Beginner's Guide: Second Edition Rating: 4 out of 5 stars4/5PowerShell 7 for IT Professionals Rating: 1 out of 5 stars1/5Windows Server 2019 & PowerShell All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsLearn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsMastering Active Directory Rating: 0 out of 5 stars0 ratingsWindows Command Prompt Rating: 0 out of 5 stars0 ratingsLearn PowerShell Scripting in a Month of Lunches Rating: 0 out of 5 stars0 ratingsWindows PowerShell in Action Rating: 4 out of 5 stars4/5Windows Command Prompt A-N Rating: 5 out of 5 stars5/5Enterprise PowerShell Scripting Bootcamp Rating: 0 out of 5 stars0 ratings
Operating Systems For You
Bash Command Line Pro Tips Rating: 5 out of 5 stars5/5Linux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsExcel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5OneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5RHCSA Red Hat Enterprise Linux 8 (UPDATED): Training and Exam Preparation Guide (EX200), Second Edition Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Linux Command Line and Shell Scripting Bible Rating: 3 out of 5 stars3/5Help! iOS 17 - iPhone: How to Use iOS17 Rating: 0 out of 5 stars0 ratingsMake Your PC Stable and Fast: What Microsoft Forgot to Tell You Rating: 4 out of 5 stars4/5Linux Bible Rating: 0 out of 5 stars0 ratingsNetworking for System Administrators: IT Mastery, #5 Rating: 5 out of 5 stars5/5Raspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratingsThe Linux Command Line Beginner's Guide Rating: 4 out of 5 stars4/5Windows 11 For Dummies Rating: 0 out of 5 stars0 ratingsThe Mac Terminal Reference and Scripting Primer Rating: 4 out of 5 stars4/5MacBook Pro User Manual: 2022 MacBook Pro User Guide for beginners and seniors to Master Macbook Pro like a Pro Rating: 0 out of 5 stars0 ratingsmacOS Sonoma For Dummies Rating: 0 out of 5 stars0 ratingsLinux All-In-One For Dummies Rating: 2 out of 5 stars2/5XDA Developers' Android Hacker's Toolkit: The Complete Guide to Rooting, ROMs and Theming Rating: 2 out of 5 stars2/5CompTIA Linux+ Study Guide: Exam XK0-004 Rating: 0 out of 5 stars0 ratingsLinux All-in-One For Dummies Rating: 3 out of 5 stars3/5Macs All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsCompTIA A+ Complete Study Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 0 out of 5 stars0 ratingsExploring Windows 11: The Illustrated, Practical Guide to Using Microsoft Windows Rating: 0 out of 5 stars0 ratingsThe Windows Command Line Beginner's Guide: Second Edition Rating: 4 out of 5 stars4/5
Reviews for PowerShell
2 ratings0 reviews
Book preview
PowerShell - Sam Griffin
Introduction
Are you looking for an easy way to simplify and automate administration of all your Microsoft products? You can’t go wrong with Microsoft PowerShell, one of the most powerful scripting languages ever devised. And don’t let the term, scripting language
scare you off either; PowerShell is remarkably easy to learn and has one of the most comprehensive support systems of any programming or scripting language.
PowerShell makes it easy to retrieve data about your system settings, manage your services, change objects and much more; learning it now will help you to reduce how much time you have to spend, or waste as the case may be, on admin functions and all without the need to purchase expensive tools or services from elsewhere. It comes built into Windows 10, so you don’t even have to go through the hassle of downloading and setting it up – it’s all there, just waiting for you to use.
In this guide, we will cover:
What PowerShell is and what its uses are
PowerShell cmdlets (commands)
PowerShell scripts
PowerShell strings and quotes
PowerShell Automation and PowerShell Remoting
Rather than having one underlying theme running through the book, I have set it out so that you can pick and choose the chapter you want to read, depending on your needs at the time.
Welcome to the wonders of Windows PowerShell.
Chapter 1: Introduction to PowerShell
Let’s start with the basics – what is PowerShell and what can it do for you?
These days, there are multiple ways for you to interact with a computer system and manage it from the GUI (graphical user interface) to the CLI (command-line interface). Some people consider the latter as a huge backward step, back to the time of those old-fashioned green-screened terminals. However, today we still use it, together with web-based interfaces and API (application programming interface) calls.
But why have we gone back to the command line? To understand that, you need to understand what goes into large-scale computer system administration. Repetitive tasks take up a lot of admin time, and it is necessary to do these as quickly and efficiently as possible, especially with multiple systems requiring management. Add to that the need to make sure those tasks are done the same way every time to ensure the right results and you start to understand why the command-line interface method is so important. One of the most common command-line interfaces is Microsoft PowerShell.
What is it?
PowerShell is an automation and scripting platform developed by Microsoft. Built on the .NET framework, it combines an interactive command environment with a scripting language, and has been described by Ed Wilson, a leading resource on PowerShell, as follows:
Windows PowerShell is an interactive object-oriented command environment with scripting language features that utilizes small programs called cmdlets to simplify configuration, administration, and management of heterogeneous environments in both standalone and networked typologies by utilizing standards-based remoting protocols.
That’s quite the definition! Let’s delve into it a bit deeper.
Explain Object-Oriented
In essence, an object-oriented programming language is a kind of logic, a way of understanding how a language or platform behaves. Everything in the language is an object. Python is perhaps the most famous of all object-oriented programming languages.
An object has at least one attribute and at least one method or function – have a look at some real-world examples:
A TV remote control – attributes include color, shape, size, how many buttons it has, etc. Functions or methods include volume adjustment, changing channels and turning the TV on and off.
A vehicle – attributes include current speed, location, license plate, etc., while methods include moving, acceleration, slowing and parking.
A dog – attributes include breed, color, energy levels and mood, while methods include barking, sleeping, running, playing, etc.
Explain Cmdlets
Short for command-lets, a cmdlet is a PowerShell command and there are lots of them. Each cmdlet is responsible for a specific task or function, and we’ll be covering them in detail in the next chapter. Behind a cmdlet, a lot is going on. When it is executed, the command works with multiple objects, methods, classes, API calls, and lots of other things, all to get its job done. The primary advantage of using PowerShell is that there is no need to understand all of this; the cmdlet takes care of everything.
To help you in using these cmdlets, PowerShell uses a naming pattern, verb-noun, to help you understand what each one is for. Some of the verbs you will encounter include Set, New, Get, Copy, and Add. Putting the verbs and nouns together gives