In the modern world, everyone strives for automation. Automating everyday tasks increases efficiency and can avoid errors caused by repetitive monotonous work. PowerShell can be used to automate such mundane tasks.
PowerShell is the latest command line interpreter from Microsoft and largely replaces its predecessors - the Command Prompt, Windows Batch as well as VBScript.
The syntax of PowerShell is reminiscent of that of the Unix shell. PowerShell works with pipes and filters, is object-oriented and, in addition to the actual console, is a cross-platform scripting language with the help of which systems can be managed, configured or tasks automated.
Current PowerShell version: 7.2.4 (found: 17.05.2022)
Windows PowerShell is simply described as an input window in which certain commands can be executed via text input. In addition, several commands or processes can be started via a text file.: Create and run Windows PowerShell script. PowerShell is considered the successor of the command prompt and thus of Windows Batch. Scripts that were originally written in VBScript are now mostly implemented in PowerShell. ... continue reading
PowerShell Help | Get-Help
Probably the most important PowerShell command is Get-Help. With Get-Help the integrated PowerShell help can be called, it gives an overview of the function of the individual commands and their application, up to concrete examples. ... continue reading
PowerShell Version: get-host
The PowerShell version can be displayed with the get-host command. ... continue reading
Powershell console commands
To begin with, it is not always necessary to write a script for PowerShell. Especially for administrators the PowerShell console offers a possibility to execute certain tasks via commands. ... continue reading
Create and run a Windows PowerShell Script
In the simplest case, a PowerShell script is a text file containing a series of PowerShell commands. A PowerShell script is understood to be a file with the extension .ps1. The script file can contain a collection of commands, functions or cmdlets. ... continue reading
PowerShell editors in comparison: ISE, Visual Studio Code
Choosing the right editor can significantly simplify development, even though PowerShell scripts can theoretically be created in any text editor. The advantages of a PowerShell-optimized editor include syntax highlighting, auto-completion, code snippets, and a debugging mode that can step through the script line-by-line and analyze specific areas. For a long time, the standard PowerShell editor was the Windows-integrated PowerShell ISE, which does a good job especially for debugging ,but the IS... ... continue reading
PowerShell: Cmdlet (enhanced Function)
In PowerShell ISE a template for a PowerShell cmdlet can be inserted with Ctrl+J. The template extends the script with elements for documentation and thus gives the integrated PowerShell help all necessary information for the cmdlet: "get-help". ... continue reading
PowerShell - Best Practice - creating better scripts
PowerShell offers relatively much freedom in designing the scripts. In order to write scripts in a readable and understandable way, it is advantageous if certain rules are followed. In PowerShell, comments can be inserted to explain the code, or information about the script and help can be stored in the header of a cmdlet, and the possible parameters can be documented. Thegoal should be that the code is written as self-explanatory as possible, which makes some comments unnecessary and simplifies... ... continue reading
PowerShell Cmdlet Help
Help in a custom cmdlet is a simple comment block at the beginning of a function, or at the beginning of a PowerShell script file. ... continue reading
PowerShell variables, data types and objects
Basics of PowerShell variables and their data types. ... continue reading
PowerShell convert string / manipulation: substring etc.
In this article I show a few examples for manipulating strings (character strings) ... continue reading
PowerShell Syntax: compare and nest
PowerShell uses so-called comparison operators for comparing values. Pipes can be used to pass different PowerShell commands to other commands. ... continue reading
PowerShell if else and switch
Test conditions with the commands if, elseif, else and switch and execute a command if they apply: if, else, ... then ... continue reading
PowerShell Loops and Array
An array stores multiple values, similar to a 2-column table. ... continue reading
PowerShell text file and csv read / write
PowerShell text file and csv read / write ... continue reading
PowerShell Hashtable vs Array vs Dictionary
If you want to store specific values for an array, you will reach the limits with arrays. A hashtable is similar to an array, but stores a value for each entry. (similar to the vbscript: Dictionary) ... continue reading
PowerShell Log-Files: Logging into a textfile - write to file
Log files in PowerShell can be created via the Out-File command, via a custom function, or via PowerShell's built-in Transcript. ... continue reading
PowerShell: File attributes: Change date - without any tools.
As an alternative to special programs, the date of a file or folder can also be changed with PowerShell. ... continue reading
PowerShell - Handling passwords.
Of course, passwords should never be stored in plain text in a script file. PowerShell offers possibilities for a secure handling of passwords. As an example, a password for a specific user can be stored encrypted as a text file. Only the respective user can decrypt the file, for other users the file is worthless. ... continue reading
PowerShell read Eventlog
With the command "Get-WinEvent" the Windows Eventlog can be accessed via PowerShell ... continue reading
Powershell ISE - Snippet | Templates
Snippets are script templates. For example a "do-until" or "for" loop or a template for a cmdlet. By selecting a snippet, the sample code is inserted into the editor. Powershell ISE, see also: how to create a PowerShell script ... continue reading