Running PowerShell scripts on Windows startup can automate essential tasks and save time.
Continue readingCategory Archives: Powershell
PowerShell String Contains Operator
PowerShell is a powerful tool for automation and administration tasks in Windows operating systems. It comes with a lot of built-in features and commands.
Continue readingWrite to the Console in Powershell
PowerShell has various methods to write output to the console. This article discusses 4 of these methods:
- Using the Write-Output cmdlet,
- Using the Write-Host cmdlet,
- Using the Write-Error cmdlet, and
- Using System.Console class,
Using PowerShell Regex Replace
There are two methods to use for text replacement in PowerShell – replace() method or -replace operator.
Continue readingSave Output From a Powershell Command to a Variable
This article discusses two ways of saving PowerShell output into a variable. In each method, we will work on examples to cement the ideas.
Continue readingRun Powershell Script With Parameters
This article discusses how to pass parameters into a PowerShell script from the command line. We will start by discussing the syntax of the needed commands and then work through some examples to apply the knowledge.
Continue readingRun Powershell Script From Bash
You can run a PowerShell script from the Bash through two steps:
- Step 1: Install PowerShell core in your system,
- Step 2: Execute your PowerShell script using the core handle
Delete files older than X using PowerShell
This article will discuss how to delete files older than x years, days, hours, or minutes using PowerShell. We will do that by breaking down the task into four ideas. After going through the four ideas, we will create the final PowerScript script you can use to delete older values.
Continue readingAdd Column to CSV in Powershell
Adding a new column into a CSV boils down to these three steps:
- Load CSV file into a PowerShell Array using Import-Csv cmdlet,
- Add the new columns,
- (Optional) Export the result into a new or existing CSV file using the Export-Csv cmdlet.
Stop a Powershell Script on Error
PowerShell errors come in two flavors – terminating and non-terminating errors.
Continue reading