In this blog post, we’ll explore using the PowerShell For loop and ForEach-Object cmdlet effectively in our scripts. The PowerShell For Loop The For loop is a traditional loop that allows us to execute a block of code a specified … Continue reading →
There are various situations where we may need to introduce delays or pauses in our scripts to ensure proper execution or to control the timing of specific actions. Here we demonstrate how to use PowerShell start-sleep to pause script execution. … Continue reading →
We can use Where-Object in PowerShell scripts to filter objects based on specific conditions. Where-Object is commonly used with collections like arrays and lists to extract only the elements that meet certain criteria. The basic syntax of Where-Object is as … Continue reading →
When it comes to making decisions and branching logic in our PowerShell scripts, we commonly use the PowerShell If statement and PowerShell Switch statement. The PowerShell If Statement The If statement is a fundamental control structure in almost every programming … Continue reading →
There a various ways we can use PowerShell to output text to a file. And we’ll discuss a few options throughout this blog. Use Set-Content and Add-Content to Output Text to a File The first approach is to use the … Continue reading →
This blog post explains how we can launch a process using PowerShell and Start-Process. In its most simplistic form, we can launch a process and essentially forget about it. In this example we’re going to launch Google Chrome. You will … Continue reading →
This post explains how to use PowerShell Copy-Item to copy a file or folder including mirror copy! Throughout this example, consider that we have created the following folder/file structure: C:\alkanesource │ file1.txt │ file2.log │ file3.zip └───alkanesubfolder │ file4.ps1 C:\alkanedestination … Continue reading →
This post explores a PowerShell Grep and FindStr equivalent using the Select-String cmdlet. Grep (Unix) and FindStr (Windows) are command line utilities used for searching text patterns within input strings and files. By using PowerShell’s Select-String cmdlet with regular expressions, … Continue reading →
This post explains how we can use the PowerShell substring method to extract and match part of a string. Before we continue, it’s important to remember that the first index of a string starts at position 0. So in the … Continue reading →
There comes a time when we want to read or write an Active Directory attribute, yet we don’t know the name of the attribute we’re looking for! This handy script will list all user and computer LDAP attributes using PowerShell … Continue reading →