Windows PowerShell For Beginners

In this PowerShell tutorial I will provide you with practice-oriented knowledge about PowerShell. Would you like to do your IT tasks better and more efficiently and would you like to use PowerShell for this? In this PowerShell tutorial you will learn the necessary basics. With practical examples, you can easily understand the tasks shown.

In this PowerShell introduction we would like to accompany you in several chapters through the different techniques of PowerShell. Starting with the simple basics through to practice-oriented scripts that will make your everyday work easier.

  • PowerShell Introduction

  • Windows PowerShell

  • PowerShell Core 6.0

  • PowerShell 7

  • PowerShell .vs cmd.exe .vs Visual Basic Script

  • What is Windows PowerShell?

  • Why PowerShell?

  • Windows PowerShell .vs PowerShell 6.0 Core .vs PowerShell 7

  • PowerShell 7

  • Invoke Windows PowerShell?

  • Go to PowerShell 7

  • Download and install PowerShell 7


  • How and where is PowerShell used?

  • PowerShell commands

  • Remote Server Administration Tools – RSAT

  • PowerShell & Pipes

  • PowerShell Filter

  • Save PowerShell output to variables

  • PowerShell Scripts

  • Programming with PowerShell

  • Create a PowerShell script

  • What is a PowerShell script ?

  • What file extension does a PowerShell script have ?

  • How do you create a PowerShell script ?

  • 3 top tools to create PowerShell scripts

  • How do you run a PowerShell script ?

  • Functions in PowerShell

  • Delete and create folders: With Windows PowerShell

PowerShell Introduction

Visual Basic Script has long been the scripting language for IT administrators and developers.

Since PowerShell has been on the market, more and more PowerShell scripts have been used to simplify and automate IT processes.

Windows PowerShell

Windows PowerShell has been available since Windows 7 and can only be used on Windows client and server systems. Windows PowerShell is preinstalled on Windows systems by default.

PowerShell Core 6.0

PowerShell Core 6.0 has been publicly available since 2018 and can be used regardless of the operating system. PowerShell is now also available on Linux, MacOS and of course Windows.

PowerShell 7

PowerShell 7 has been publicly available since March 4th, 2020 and can be used regardless of the operating system. PowerShell 7 brings more new features and a compatibility mode for older PowerShell commands.

PowerShell .vs cmd.exe .vs Visual Basic Script

Now I want to show you a figure that shows how relevant PowerShell is to Visual Basic and CMD. You can see that the use and popularity of PowerShell has been increasing steadily since 2004.

PowerShellVisual Basic Scriptcmd.exeFrom Windows 7: Integrated PowerShell Console to query and make changes to the operating system and applications.No console included in the operating system.Old Windows console still used for standard commands like ping and . co is used.PowerShell is a framework and is based on CMDLETs, which are commands that are added as PowerShell modules. PowerShell modules are constantly being developed and are manufacturer-independent.Visual Basic has built-in commands that are limited in their functionality.The CMD uses so-called batch files that are only rarely used.PowerShell works with objects and pipes, making complicated queries easier to process.Visual Basic is limited in use and, in my opinion, not that flexible.The Command Prompt has text-based processing and can call applications that first have to be programmed at great expense and are available as Windows programs *.exe.PowerShell is 2018 operating system independent and is available as PowerShell Core. PowerShell can now be used for Linux, Mac OS and of course still for Windows.Visual Basic is a Microsoft scripting language. However, Microsoft is increasingly relying on PowerShell.The cmd.exe is only available for a Windows operating system. It is used for older applications and standard commands like "ping".

What is Windows PowerShell?

Windows PowerShell is a framework developed by Microsoft based on the .Net Framework.

Windows PowerShell essentially consists of two components. Once the PowerShell Interpreter and the actual PowerShell script language.

PowerShell Interpreter The PowerShell Interpreter is an application that translates PowerShell commands into understandable machine code.

PowerShell scripting language The scripting language for PowerShell is object-oriented and therefore simply structured.

The application for Windows PowerShell is called. “powershell.exe”. When you start this application, you will get a console similar to the “cmd” console. However, the PowerShell console is shown in blue. If you are using a Windows operating system higher than Windows XP, just search for PowerShell and open it.

Now you can enter a command in this PowerShell console.

For example, let’s take the command to list all processes on the Windows system on which you just started powershell.exe.

The command is called: Get-Process


With this command you can see all the processes that are currently running on your Windows system. For example, you could now end some processes, display more information about a specific process, or restart a process and so on.

But before you dig deep, let’s learn a few important basics.

Why PowerShell?

Windows PowerShell is installed by default from Windows 7 and can be used in all subsequent Windows versions. From Windows Server 2012 R2 onwards, most graphical server tools use PowerShell commands in the background, which are only displayed graphically for the administrator.

PowerShell modules are provided by the most well-known technology manufacturers in the world. With these PowerShell modules you can use PowerShell to access and administrate the manufacturer’s hardware.

Microsoft has built such PowerShell modules for all of their products. You can use PowerShell to manage all Windows versions from Windows Server 2008 with PowerShell. Furthermore, you can simultaneously administrate all Windows applications such as Active Directory, DNS, Exchange, Hyper-V, file servers, etc. with PowerShell.

With the right PowerShell knowledge, you can complete your tasks more efficiently and easily.

With the introduction of PowerShell Core 6.0 on January 12, 2018, PowerShell has become operationally independent. With PowerShell Core 6.0, the commands and scripts written in Windows can also be executed on a Linux derivative. The other way around too, of course.

In this PowerShell tutorial you will learn how to best use PowerShell. With simple practical examples, I will show you PowerShell as you can use it in your everyday life.

I wish you lots of success and fun learning PowerShell in this free PowerShell tutorial.

Windows PowerShell .vs PowerShell 6.0 Core .vs PowerShell 7

Since the beginning of the year, on January 12th, 2018, the media started with the news that PowerShell 6.0 Core was publicly available. PowerShell 6.0 Core is intended to extend Windows PowerShell, which has been known in the Windows world and beyond for years.

PowerShell Core 6.0 is not a successor to Windows PowerShell in that sense. It’s a picture of that. The main difference between PowerShell Core 6.0 and Windows PowerShell is that PowerShell Core 6.0 is not based on the .Net Framework but on the .Net Core Framework. This means that it can also be used on other operating systems than Windows, such as Linux or MacOS.

With PowerShell 7, Microsoft has opened another milestone.

PowerShell 7 brings us more possibilities in scripting and using PowerShell. Furthermore, PowerShell 7 has a compatibility mode for Windows PowerShell commands.

Thus, Windows PowerShell remains the most used scripting tool in the Windows world. Hence the name “Windows PowerShell”. I guess with PowerShell 7 that will change in the next few years. So that Windows administrators use PowerShell 7 as standard.

I’ll cover the basics in this PowerShell tutorial. So that you can use them in Windows PowerShell as well as in PowerShell 6.0 Core and PowerShell 7.

PowerShell 7

PowerShell 7 is available since March 2020 after 2 years of development . 

PowerShell 7 is the successor to Windows PowerShell and PowerShell Core.

In this blog post, I will explain why Microsoft released PowerShell 7.

In addition, I will show you what the advantages of PowerShell 7 are and how to download and install it.

Invoke Windows PowerShell?

Windows Powershell is called with “powershell.exe” as described in the introduction. Windows Powershell is from Windows and does not have to be installed separately.

Go to PowerShell 7

PowerShell 7 is not yet part of the Windows operating system. with the next Windows version PowerShell 7 will be included by default. However, Microsoft has published the installation files for everyone who wants to use PowerShell 7. So that you can post-install Powershell 7.

Here are a few links where you can download PowerShell 7 and the corresponding instructions on how to install PowerShell 7 on Windows. If you want to install PowerShell 7 on Windows, download the .msi. Installing PowerShell is super easy with an MSI.

Download and install PowerShell 7

To download and install PowerShell 7 , please go to the following link.

After you have downloaded PowerShell 7 you can install it eg on your test system.

After you install PowerShell 7, you can open the console and test PowerShell

Once you have the PowerShell 7 console open, enter the command there .


You will now see information about the current PowerShell version.

Here the PS version should have at least the value 7.XX. If so, then you are currently using PowerShell 7.

Have fun trying it out .


Here is a small representation of how script processing and command processing has developed over the years. Starting from the cmd console, which was already in use in IBM computers in 1981 and in 2018 we can use PowerShell cross-platform.

So, that’s been a little story in the world of PowerShell for now. Now I would like to jump into the basic introduction of PowerShell with you.

I would like to first show you which platform PowerShell is used for and then let’s look at the PowerShell methods to control or administrate this system. At the beginning it is very important to understand how and where PowerShell can be used or is already being used. The systems described are examples from practice.

How and where is PowerShell used?

Let’s assume you work a lot with Windows systems, then you can use PowerShell to administrate the following systems, among others. There’s a lot more, but first I’d like to show you where PowerShell is used in practice, for example.

Windows System

  • Windows Server 2008

  • Windows Server 2008 R2

  • Windows Server 2012

  • Windows Server 2012 R2

  • Windows Server 2016

  • Windows Server 2019

Windows server applications

  • Activce Directory

  • DNS

  • DHCP

  • Exchange Server

  • Fileserver

  • Hyper-V

  • Failover Clustering

  • Storage Spaces Direct

  • Storage Replica

  • Printserver

  • IIS Web Services

Windows basic configuration

  • network adapter

  • network teaming

  • Disks

  • Firewall

  • Proxy

  • Registry

  • files and folders

Third Party Storage Hardware Administration

  • Disks

  • SMB

  • Raid Controller

  • SAN

  • iSCSI

  • Storage Controller

Hyper-V Administration

  • VMs

  • Hyper-V Hosts

  • VMs Disks

  • virtual network

  • virtual disks

Azure Administration

  • VMs in Azure

  • Azure Site Recovery

  • Azure Ressource Manager

  • Azure Services

But before you can administer the individual systems with PowerShell, let’s first go into the PowerShell basics, which I would like to show you now.

PowerShell commands

PowerShell Module und CMDLETS

PowerShell itself is a platform that provides an interpreter. The real PowerShell power comes from the modules that are developed by the manufacturers and by the community. For example, Microsoft develops PowerShell modules for Active Directory, Windows Server and so on. For their products. Another company develops PowerShell modules for your applications or hardware.

A single module usually consists of several functions, these are called cmdlets in PowerShell.

Here’s an example:

If you want to administrate Active Directory with PowerShell, then you have to load the “ActiveDirectory” module in PowerShell. If you log on to a domain controller and call up PowerShell there, the PowerShell module is already preinstalled.

Remote Server Administration Tools – RSAT

If you want to administrate Active Directory via your Windows client with PowerShell, then install the RSAT package.

After installing RSAT on your client, open the PowerShell console and type Get-Module.


Import the Active Directory module with Import-Module activedirectory


If you now run the “Get-Module” command, you will now see the imported Active Directory module.


As soon as the “ActiveDirectory” module is installed or if you are logged on to a domain controller, you can use the “CMDLETS” such as

New-ADUSer Get-brought the

The CMDLETS are basically functions that can do something. Like creating new users with “New-ADuser” or displaying users with “Get-ADUser”.

The most common PowerShell command types – Get, Set, Enable, Remove, Disable, Add, New As you have already noticed, the PowerShell commands always follow the same syntax. Depending on the function of the command, it begins with a specific word. e.g. “Get-“. Get means to get in English. Say with this command you want something displayed.

Here is a representation of the basic types of commands that you will find in PowerShell, among other things. Of course, the correctness depends on the module or CMDLET that you use and who programmed it.

  • Get display a value.

  • Get-Process

  • Get-NetAdapter

  • Get-Host

  • Set Add a value i.e. adjust something.

  • Set-ACL

  • Set-DnsClient

  • Set-NetAdapter

  • New Create a new share or create a new file.

  • New-NetAdapterAdvancedProperty

  • New-FileShare

  • New-Item

  • Remove & Stop Delete a file or end a Windows process.

  • Remove-Item

  • Stop-Process

Whatever task you want to accomplish with PowerShell, first check the requirements.

Before you can use a command with PowerShell or before you write a PowerShell script, you should be clear about what you are doing, i.e. what the goal is and whether it is worth writing a PowerShell script.

Don’t get me wrong, I’m a big fan of PowerShell and it makes everyday IT life a lot easier. But before you want to complete a task with PowerShell, you should ask yourself a few questions to find out whether you just take a command, write a script, or prefer to complete the task in a different way.

I will describe the process in a little more detail; in everyday life, with a little experience, you would already have the decision in your head in a few seconds or minutes. The important thing is that you already have a few thoughts in mind.

So that you can quickly decide whether to complete a task with PowerShell or use another method, you should ask yourself the following questions:

  1. Is there a PowerShell interface that can be used to do the job?

  2. Does the task come up frequently or is it a one-time thing?

  3. If it’s a one-time thing? Is it possible easier and faster via the GUI?

If you find this to be a task that you have to do over and over again, then this is a wonderful candidate for PowerShell.

Is it a one time command? or do you need a script?

If you have to perform a task recurring every day, then it is worth writing a script. The script would then contain the command that you would otherwise have to run every day, such as deleting a file.

Remove-Item -Path "path to file"

It’s a simple example, but you get the point. Automate repetitive tasks that keep you from your essential work with PowerShell.

PowerShell & Pipes

In PowerShell, pipes are a method of routing something. Pipes means “tube” in German and is the synonym in PowerShell to transport something that is then processed on the other side and then possibly. is transported again.

An example:

You want to end the OneDrive process on your server or client.

With “Get-Process” you get all Windows processes and can check what the OneDrive process is called in Windows.

First of all, we only display the process name and the ID by further “pipening” the output. Piping is represented by the “|” character in PowerShell.

Get-Process | Format-Table ProcessName, Id

Now that we know what the OneDrive Windows process is called, we can end it.

This can be done with the “Stop Process” command.

Stop-Process -Name onedrive

Alternatively, we could look for the “onedrive” process and then pipe to the “Stop-Process” command.

Get-Process -Name onedrive | Stop-Process

You can also restart the process with PowerShell using the “Start-Process” command.

Start-Process onedrive

If we look for the “onedrive” process again, we see that it is accessible again.

PowerShell Filter

Of course, PowerShell also has filter functions. 

There are filters that are already provided by the command. However, if such a filter function is not sufficient or does not exist at all, then you can access the PowerShell filter functions.

The filter function in PowerShell is called “where” or simply “?”. The filter function is used using the pipe function. Let’s go straight to the examples to make it clearer.

Here is a filter function provided by the “Get-Process” command. You can enter the name of the window process and only this process will be displayed.

Get-Process -Name onedrive

However, you can also achieve the same thing with the where command in PowerShell. Enter the command “where” after “pipe”.

Get-Process | where {$_.ProcessName -eq „onedrive“}

But let’s assume you know which Windows process you want, but