8 Best PowerShell Extensions for Visual Studio Code

Best PowerShell Extensions for Visual Studio Code

If you’re working in PowerShell, this tutorial will be very helpful to you. I have explained here the eight best PowerShell extensions for Visual Studio Code. Each one brings unique value to scripting, testing, collaboration, and cloud automation. Extension Name Key Benefit Why I Recommend It PowerShell (Microsoft) Core scripting, IntelliSense, Debug Must-have, official Pester … Read more

How to Set and Get Environment Variables in PowerShell

Set and get environment variables in PowerShell

To set an environment variable in PowerShell, assign it with $env:, and to get it, read $env: the same way. This lasts until you close the window: Output: To keep a variable after you close PowerShell, save it to the User or Machine scope with [Environment]::SetEnvironmentVariable. Below I cover every way to set, get, persist … Read more

How to Create a Registry Key with PowerShell If It Does Not Exist?

Create a Registry Key with PowerShell If It Does Not Exist

As a system administrator, sometimes you might need to manage Windows registry settings across multiple machines. So, sometimes, you might need to check for the existence of a registry key and create it if it is missing using PowerShell. In this tutorial, I will explain how to create a registry key with PowerShell if it … Read more

How to Remove Environment Variables in PowerShell?

Recently, one user asked me about removing environment variables in PowerShell. PowerShell provides a few different ways to delete environment variables. In this tutorial, I will explain how to remove environment variables in PowerShell. Environment variables are used to store system-wide values that affect the behavior of processes and applications. They are part of the … Read more

How to Delete User Profiles Older Than 30 Days Using PowerShell?

As an IT administrator, managing user profiles on Windows computers is an important task to free up disk space and keep systems running smoothly. Over time, user profiles can accumulate and consume valuable storage, especially on shared devices. In this tutorial, I’ll walk you through how to use PowerShell to automatically delete user profiles older … Read more

How to Delete Contents of Folder in PowerShell?

Delete Contents of Folder in PowerShell

It is easy to delete the contents of a folder using PowerShell. Do you have a similar requirement? In this blog post, we’ll explore different methods to delete the contents of a folder using PowerShell with complete scripts. To delete the contents of a folder in PowerShell, use the Remove-Item cmdlet with the path to … Read more

How to Remove a Computer from a Domain Using PowerShell

Remove a computer from a domain with PowerShell

To remove a computer from a domain with PowerShell, run Remove-Computer as administrator, name the workgroup to join and restart: The credential needs rights to remove the computer account. Below I check the join state, preview the command, remove remote PCs and clean up AD. My test PC isn’t on a domain, so I used … Read more

Set Password Never Expires for a Local User in PowerShell

Set password never expires for a local user with PowerShell

To set a local user’s password to never expire, run Set-LocalUser with -PasswordNeverExpires $true in PowerShell as administrator: It works in PowerShell 7 and Windows PowerShell 5.1. Below I check which accounts already never expire, preview the change, show two other ways and cover domain accounts. I didn’t change any accounts on my PC. Check … Read more

How to Change the Wallpaper with PowerShell

Change the wallpaper with PowerShell

To change the wallpaper with PowerShell, call the Windows SystemParametersInfo function with the image path. Add-Type makes it available, and the change shows right away without signing out: It returns True when Windows accepts the image, affects only the signed-in user and needs no admin rights. Below I set the fit style, wrap it in … Read more

How to Open PowerShell in a Folder (Windows 11 and 10)

Open PowerShell in a folder

To open PowerShell in a folder, open the folder in File Explorer, click the address bar, type pwsh (or powershell for Windows PowerShell 5.1) and press Enter. PowerShell starts with that folder as its location. In Windows 11 you can also right-click inside the folder and choose Open in Terminal. Below I cover shortcuts, command-line … Read more