Powershell

17 posts

2021

How to find the Powershell version in Windows

How to find your PowerShell version using $PSVersionTable. Includes version history and Windows PowerShell vs Core.

How to Replace Part of a String Using Powershell

How to replace text in a string in PowerShell using .Replace(), the -replace operator, and regex patterns.

How to detect if Powershell is installed - C#

How to check if PowerShell is installed on a Windows machine before running scripts from C#.

Importing and exporting csv files with Powershell

How to import and export CSV files in PowerShell using Import-CSV and Export-CSV commands.

Import data from a text file into Powershell

How to read and import text file content into PowerShell using Get-Content.

Get the path relative to the script location - Powershell

How to get the current script path in PowerShell using $PSScriptRoot and $MyInvocation.

Adding single and multi-line comments in Powershell

How to write single-line and multi-line comments in PowerShell using # and <# #> syntax.

How to repeatedly start a service that failed to stop - Powershell

How to retry stopping and restarting a Windows service in PowerShell when it fails to stop in time.

Passing multiple parameters into a function in Powershell

How to pass multiple parameters into a PowerShell function correctly, avoiding common syntax mistakes.

Creating objects using New-Object in Powershell

How to create objects in PowerShell using New-Object and PSCustomObject, with practical examples.

How to find and stop processes using Powershell

How to use Get-Process and Stop-Process in PowerShell to find and kill running processes.

Add your IP address as an NSG rule in Azure using Powershell

How to add your IP address to an Azure Network Security Group using PowerShell.

Getting your public IP address using Powershell

How to get your public IP address using PowerShell with a single command.

Passing each element of an array into a function with Powershell

How to loop through an array and pass each element into a function in PowerShell using ForEach.

Getting and setting Execution Policy in Powershell

How to use Get-ExecutionPolicy and Set-ExecutionPolicy in PowerShell to manage script permissions.

How to Get-Help in Powershell

How to use Get-Help in PowerShell to find documentation for any command directly from the terminal.

Loading scripts disabled on this system - Powershell

How to fix 'ps1 cannot be loaded because running scripts is disabled on this system' in PowerShell on Windows.