PowerShell
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.4.6 (found: 2024-10-23)
Basics: Start console, execute commands
PowerShell allows you to control or manage systems using the command line or run automated operations via Powershell scripts. ... continue reading
Basics: 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 Basics: Data, Loops and Conditions
Powershell arrays and objects and logic: If queries and loops. ... 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 - 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 text file and csv read / write
PowerShell text file and csv read / write ... continue reading
Using PowerShell to set file system permissions: ACL
To add a user with write permissions to an existing folder, the following script can be used: ... continue reading
PowerShell: Prevent screen saver, lock: Move mouse regularly
Alternatively, if you can't change the screen lock settings, you can move the mouse regularly, or have a script move the mouse. Originally published as an AutoIt script, I recreated the script with a few PowerShell lines. Anyone who copies the following commands into a PowerShell session will prevent the computer from locking the screen or starting the screensaver: ... continue reading
Restore file version history
The PowerShell script presented here copies the latest files of the file version history to any folder or to another computer. In the copy, the date is removed from the file name, thus restoring the original file names. ... continue reading
PowerShell task scheduling: restart computer or server
A scheduled task in Windows can of course also be created via PowerShell. ... continue reading
PowerShell: Read Active Directory data
Using Windows PowerShell to read Active Directory objects. ... continue reading
PowerShell TCP Listener
PowerShell uses the following commands to open a socket on a specific port via System.NET: ... 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