Book Image

Learn PowerShell Core 6.0

By : David das Neves, Jan-Hendrik Peters
Book Image

Learn PowerShell Core 6.0

By: David das Neves, Jan-Hendrik Peters

Overview of this book

Beginning with an overview of the different versions of PowerShell, Learn PowerShell Core 6.0 introduces you to VSCode and then dives into helping you understand the basic techniques in PowerShell scripting. You will cover advanced coding techniques, learn how to write reusable code as well as store and load data with PowerShell. This book will help you understand PowerShell security and Just Enough Administration, enabling you to create your own PowerShell repository. The last set of chapters will guide you in setting up, configuring, and working with Release Pipelines in VSCode and VSTS, and help you understand PowerShell DSC. In addition to this, you will learn how to use PowerShell with Windows, Azure, Microsoft Online Services, SCCM, and SQL Server. The final chapter will provide you with some use cases and pro tips. By the end of this book, you will be able to create professional reusable code using security insight and knowledge of working with PowerShell Core 6.0 and its most important capabilities.
Table of Contents (26 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

Executing PowerShell without PowerShell.exe


The next important topic addresses one of the top myths around PowerShell security:

:

The first three of the top myths you have already learned about. The last one is about the problem that many defenders still think exists today: blocking PowerShell.exe will also block PowerShell in general. As you know, PowerShell is based on .NET, and in detail, it uses the System.Management.Automation namespace. Therefore, System.Management.Automation.dll will be loaded to execute PowerShell cmdlets.

Note

The documentation for the API for System.Managamenent.Automation.dll can be found at the following link: https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.

The first example shows how the dll can be loaded and used without PowerShell.exe. For this scenario, a small C# program is created. First, take a look at the C# code, which is saved as plain text to a *.cs file in your example prog.cs:

using System;
using System.Configuration.Install;...