Category: PowerShell

PowerShell & Windows Admin Blog Archives, by Peter Whyte, an experienced SQL Server Database Administrator.

  • Removing Quotes from Multiple CSV Files in a Directory Using PowerShell

    Managing CSV files often involves cleaning up data before processing. A common task is removing unwanted quotation marks from the contents of CSV files. I wrote a blog post on how to remove quotes from a single CSV file using PowerShell some years ago, which I have just…

    Read More


  • How to Set Environment Variables in PowerShell

    To get environment variables in PowerShell, we can use Get-ChildItem env: to list all the environment variables and $env: to return the value of a specific environment variable. This blog post should help explain this as well as how to set new values for Environment Variables. An environment…

    Read More


  • How to Silently Install SSMS

    This is a note on how to silently install SQL Server Management Studio (SSMS) via command (PowerShell). SSMS is a tool most people use when working with SQL Server. If you need to install SSMS on multiple computers, you may want to use the silent installation feature for…

    Read More


  • How to Delete Files in PowerShell

    This is a post on how to delete files in PowerShell, which will be useful when you need to delete files as part of a script in Windows. This post covers the following:# PowerShell: Delete a File# PowerShell: Delete a Folder# PowerShell: Delete Files in Subfolders Recursively PowerShell:…

    Read More


  • Create a New Firewall Rule with PowerShell

    This is a short post to share a PowerShell script that will create a new Windows Firewall Rule on a your computer. We have to ensure that we run PowerShell as Administrator for this to work. The above is creating a new firewall rule so inbound SQL Server…

    Read More


  • How to Check PowerShell Version

    This post is a guide on how to check your PowerShell version on a Windows computer. I’m using $PSVersionTable to get this info. It’s important to keep all software as up-to-date as possible, we all know it. Being on the latest PowerShell version is especially required if you…

    Read More


  • How to Automate PowerShell Scripts with Task Scheduler

    Running PowerShell scripts on a schedule is a common requirement for Windows Admins. This guide will show you how to automate your scripts using Task Scheduler, covering both the GUI and PowerShell methods. Task Scheduler allows you to run programs, scripts, or other tasks based on a schedule…

    Read More


  • SQL Server Default Port

    The default port for the SQL Server Engine is 1433, which is a key thing to know if you’re working as a Database Administrator (DBA), especially when managing network configurations or troubleshooting connectivity issues. In my experience, SQL Server runs on port 1433 about 95% of the time.…

    Read More


  • Restart Services on Multiple Hosts using PowerShell

    In this post, we’ll walk through a script that restarts services on multiple remote hosts using PowerShell. A single PowerShell command will be run on several computers at the same time. If you need to run a command on multiple remote machines, the PowerShell Invoke-Command cmdlet is a…

    Read More


  • PowerShell ForEach Loop Tutorial

    Looping is a fundamental concept in PowerShell, and in programming in general. It’s needed for various situations where we need to work with one object at a time within an array/collection of objects. Microsoft’s documentation on this, about Foreach : Microsoft Documentation, describes Foreach to be for ‘stepping…

    Read More