Master PowerShell Tricks Volume 3
Master PowerShell Tricks Volume 3
About the Book
“PowerShell is awesome.” I’ve lost track of how many times I’ve heard this phrase and I never get tired of hearing it..
I remember the launch of Windows Server 2012 like it was yesterday. It was a major release with innovation across the board in Hyper-V, Storage, Networking, Scale and Performance. Underlying all of this innovation was one unifying investment designed to make it easier for you to harness these technologies: PowerShell. With over 2500 PowerShell commandlets built-in, rich automation was now in everyone’s hands. Over the years, we listened as you used PowerShell for everything from simple repeatable tasks to complex deployments of servers, software and services where PowerShell removed human error.
A few releases later, we’ve added over a thousand new commandlets, Desired State Configuration (DSC), and Just Enough Administration (JEA) making PowerShell an indispensable and valuable skill for every résumé. If you haven’t learned PowerShell yet, there’s no time like the present. (Spoiler alert: It’s fun too…) The authors are PowerShell experts and MVPs who teach and coach in the Microsoft community with years of experience. In addition, they have used their learnings in the community to provide feedback to the PowerShell team and help influence the product direction. Whether you or a seasoned user or a PowerShell newbie, you can’t ever know too many PowerShell Tricks.
Windows Server/Hybrid Cloud
Foreword by: Jeff Woolsey iii
From Dave iv
About the Authors v
Dave Kawula - MVP v
Thomas Rayner - MVP vi
Allan Rafuse – MVP vii
Will Anderson – MVP viii
Mick Pletcher – MVP ix
Technical Editors x
Cristal Kawula – MVP x
Emile Cabot - MVP xi
Cary Sun – CCIE #4531 (Future Microsoft MVP) xii
North American MVPDays Community Roadshow 20
Sample Files 21
Additional Resources 21
Chapter 1 23
Using PowerShell to Download Drivers via FTP 23
Chapter 2 27
Using PowerShell to Download Videos from Channel 9 27
Chapter 3 35
Snapshot Management of VMware with PowerShell 35
Snapshot Management 35
Password Issues 36
Report Output 36
The Code (VMWare Example) 37
Chapter 4 42
Setting SQL Server Memory Allocation (Maximum and Minimum) 42
Retrieving the Physical Memory 42
Determine SQL Server Maximum Memory 43
Reconfigure SQL Server Memory Allocation 44
Making IT Work 46
Chapter 5 47
Using PowerShell to Add a Direct Member to an SCCM Collection 47
Chapter 6 49
Using PowerShell to Manage the Datadog Cloud Service 49
Example Snippets 50
Searching for Events 53
Chapter 7 55
Using PowerShell to Update the .Default and All User Profiles Registry 55
Enumerate all the existing user profiles 55
Add the .DEFAULT user profile to the list of existing profiles 56
Iterate through all the profiles 56
Manipulate the users’ registry 57
If the Profile hive was loaded by script, unload it 58
Chapter 8 60
Working with PowerShell Active Directory Module as a Non-Privileged User 60
Chapter 9 62
Using PowerShell to Split a String Without Losing the Character You Split On 62
Chapter 10 65
What's the difference between -split and .split() in PowerShell? 65
Chapter 11 68
PowerShell Rules for Format-Table and Format-List 68
Chapter 12 70
The Difference Between Get-Member and .GetType() in PowerShell 70
Chapter 13 73
Dynamically Create Preset Tests for PowerShell 73
Chapter 14 77
Piping PowerShell Output into Bash 77
Chapter 15 78
How to List All the Shares on a Server using PowerShell 78
Chapter 16 81
Get a ServiceNow User Using PowerShell 81
Chapter 17 83
Add a Work Note to a ServiceNow Incident with PowerShell 83
Chapter 18 86
Use PowerShell to see how many items are in a Directory 86
Chapter 19 87
Add a Column to a CSV using PowerShell 87
Chapter 20 90
Diagnosing slow PowerShell Load Times 90
Chapter 21 91
Use Test-NetConnection in PowerShell to see if a Port is Open 91
Chapter 22 92
Use PowerShell to find out How Long it is until Christmas 92
Chapter 23 94
Use PowerShell to Figure out “What day of the week” x number of days from now 94
Chapter 24 96
Using Get-Member to Explore Objects 96
Chapter 25 99
Using Select-Object to Explore Objects 99
Chapter 26 104
Can PowerShell Parameters Belong to Multiple Sets? 104
Chapter 27 106
Opening an Exchange Online Protection Shell 106
Chapter 28 108
Import Active Directory Module into Windows PE 108
Chapter 29 120
Using PowerShell to report on Windows Updates installed during MDT OSD Build 120
Chapter 30 130
Report on Mapped Drives to understand Cryptolocker Vulnerabilities with SCCM and PowerShell 130
Chapter 31 141
Set Windows Features and Verify with PowerShell 141
Chapter 32 148
Uninstall an Application by Name with PowerShell 148
Chapter 33 151
Azure Automatic Account Creation and Adding Modules using PowerShell 151
Creating the Azure Automation Account 151
Creating a Blob Container in AzureRM 153
Upload a Blob Container 155
Chapter 34 157
Configuring Azure Automation Runbooks and Understanding Webhook Data using PowerShell 157
Creating the Runbook Script 158
Publish the Runbook 160
Create an Alert 161
Validating our Data 165
Chapter 35 169
Utilizing Webhook Data in Functions and Validate Results using PowerShell 169
Building on Webhook Data 169
Chapter 36 180
Adding Configuration to your Azure Automation Account using Azure DSC 180
Push vs. Pull 181
Pros and Cons to Each 182
Things to Consider 183
Upload the Configuration 186
Compile the Configuration 189
Chapter 37 194
Onboarding Automation DSC Endpoints and Reporting 194
Register the Virtual Machine 195
Apply a Configuration 197
Azure Automation DSC Reports 199
Connecting to Log Analytics 201
Chapter 38 206
Publishing Configurations and Pushing them with Azure DSC 206
Publish the Configuration 206
Install the VM Extensions 208
Chapter 39 212
Testing RDMA Connectivity with PowerShell 212
Chapter 40 223
Storage Spaces Direct Network Reporting HTML Script for Mellanox Adapters via PowerShell 223
Chapter 41 227
Using PowerShell and DSC to build out an RDSH Farm from Scratch 227
Chapter 42 248
Join us at MVPDays and meet great MVP’s like this in person 248
Live Presentations 248
Video Training 248
Live Instructor-led Classes 249
Consulting Services 249
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
C++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
A Guide to Artificial Intelligence in HealthcareDr. Bertalan Mesko
Can we stay human in the age of A.I.? To go even further, can we grow in humanity, can we shape a more humane, more equitable and sustainable healthcare? This e-book aims to prepare healthcare and medical professionals for the era of human-machine collaboration. Read our guide to understanding, anticipating and controlling artificial intelligence.
Atomic KotlinBruce Eckel and Svetlana Isakova
For both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
C++ Best PracticesJason Turner
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Introducing EventStormingAlberto Brandolini
The deepest tutorial and explanation about EventStorming, straight from the inventor.
Ansible for DevOpsJeff Geerling
Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Everyday Rails - RSpecによるRailsテスト入門Junichi Ito (伊藤淳一), AKIMOTO Toshiharu, 魚振江, and Aaron Sumner
RSpecを使ってRailsアプリケーションに信頼性の高いテストを書く実践的なアドバイスを提供します。詳細で丁寧な説明は本書のオリジナルコンテンツです。また、説明には実際に動かせるサンプルアプリケーションも使用します。本書は2017年版にアップデートされ、RSpec 3.6やRails 5.1といった新しい環境に対応しています！さあ、自信をもってテストできるようになりましょう！
R Programming for Data ScienceRoger D. Peng
This book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
The Hundred-Page Machine Learning BookAndriy Burkov
Everything you really need to know in Machine Learning in a hundred pages.
Continuous Delivery PipelinesDave Farley
This practical handbook provides a step-by-step guide for you to get the best continuous delivery pipeline for your software.
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before...
All the Books of The Medical Futurist
6 BooksWe put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon...
3 BooksBuy every PowerShell book from Adam Bertram at a 20% discount!
Cisco CCNA 200-301 Complet
4 BooksCe lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301.
Software Architecture and Beautiful APIs
2 BooksThere is no better way to learn how to design good APIs than to look at many existing examples, complementing the Software Architecture theory on API design.
Linux Administration Complet
4 BooksCe lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...
Learn Git, Bash, and Terraform the Hard Way
3 BooksLearn Git, Bash and Terraform using the Hard Way method.These technologies are essential tools in the DevOps armoury. These books walk you through their features and subtleties in a simple, gradual way that reinforces learning rather than baffling you with theory.
9 Books-Bundle: Shut Up and Code!
9 Books"Shut up and code." Laughter in the audience. The hacker had just plugged in his notebook and started sharing his screen to present his super-smart Python script. "Shut up and code" The letters written in a white literal coding font on black background was the hackers' home screen background mantra. At the time, I was a first-year computer...
2 BooksDocker and Kubernetes are taking the world by storm! These books will get you up-to-speed fast! Docker Deep Dive is over 400 pages long, and covers all objectives on the Docker Certified Associate exam.The Kubernetes Book includes everything you need to get up and running with Kubernetes!
CCDE Practical Studies (All labs)
3 BooksCCDE lab