PowerShell ForEach [Looping Through Collections]

PowerShell ForEach

PowerShell’s foreach is a looping structure that helps automate repetitive tasks when working with collections of data. It comes in two forms: the foreach statement (a language construct) and ForEach-Object (a cmdlet often aliased as %). Both allow you to iterate through items in a collection and perform operations on each element, but they work … Read more

How to Delete User Profiles Using PowerShell in Windows 11?

One of my clients recently wanted us to delete old and unused user profiles from Windows 11 as they took up valuable disk space. You can manage user profiles using PowerShell. In this tutorial, I will explain how to delete user profiles using PowerShell in Windows 11. Note: Ensure you have administrative access to the … Read more

How to Generate SSH Keys with PowerShell

Generate SSH Keys with PowerShell

Recently, I was working on a project where I needed to set up secure connections between multiple servers. The issue is that most SSH key generation tutorials focus on using OpenSSH in Linux or Git Bash on Windows. However, PowerShell provides ways for SSH key management natively in Windows. In this article, I explain simple … Read more

How to Open PowerShell in a Folder?

Are you tired of navigating through multiple folders in the command prompt just to reach your desired directory? Do you wish there were a faster and more efficient way to open PowerShell in a specific folder? I’ll walk you through several methods to quickly open PowerShell in any folder on your Windows machine. Method 1: … Read more

How to Show Logged-In Users with PowerShell

Show Logged-In Users with PowerShell

Recently, I got a requirement to show logged-in users. In this tutorial, I will explain how to show logged-in users with PowerShell. For each method, I will provide you with some real-world examples. Note: You need to have administrative privileges on the machine, and you should have PowerShell 5.1 or later installed. Now, let me … Read more

How to Add a Computer to a Domain Using PowerShell

In today’s tutorial, we will discuss an advanced topic. Here, I will explain how to add a computer to a domain using PowerShell. This will help you to add computers to your domain, ensuring they are correctly configured and managed within your network. Prerequisites Here are some prerequisites that you should follow before trying to … Read more

Set the Default Printer Using PowerShell in Windows

Recently, I was helping an organization automate their workstation setup process, and one of the requirements was to set the default printer via script. If you manage multiple computers or frequently need to switch your default printer, it’s a good idea to use PowerShell. In this tutorial, I will show you several ways to set … Read more

Set Password Never Expires for Local User Using PowerShell

Recently, I was working on a project where I had to manage several local user accounts on multiple Windows machines. One common requirement was to set certain accounts to have passwords that never expire, especially for service accounts where password changes could cause service interruptions. While you can do this manually through the GUI, it … Read more

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.