Category: PowerShell

  • SQL Agent 2016 Jobs Running PowerShell Scripts

    SQL Agent 2016 Jobs Running PowerShell Scripts

    I recently performed a side-by-side upgrade of a SQL Server 2008 R2 instance to SQL Server 2016 RTM. This particular instance had over 200 SQL Agent jobs running various PowerShell scripts. After the upgrade I had to modify nearly all of those PowerShell scripts because of a bug with the PowerShell SQLSERVER provider that is […]

  • Compare paths with PowerShell

    Compare paths with PowerShell

    The other day I came across the need to compare two different paths for equality. The most annoying part of this task is when the paths are directories and you need to worry about the trailing slash. PowerShell provides a simple solution with minimal code. First let’s look at the manual method [shell]#Paths $path1 = “C:\fake\” […]

  • QS-Config v2.0 Enters Open Beta: Major Refactoring

    QS-Config v2.0 has passed closed beta and is now entering open beta. Feature changes / additions: Supports PowerShell v2.0 and higher. Supports SQL Server 2014. One script for all supported versions of SQL Server, rather than a script per version. Supports FILESTREAM. Exposed explicit control over installation directories. Behind the scenes changes / bug fixes: […]

  • Multiple Server Management – Finding the Database Server

    Multiple Server Management – Finding the Database Server

    Often database administrators must ask themselves a simple, yet tedious question, “what server is that database on,” or maybe, “how many servers do we still have on SQL Server 2005?” This article will cover how to use SQL Server’s Central Management Server to manage your server list and it will demonstrate how to use T-SQL […]

  • PowerShell Start-Job

    PowerShell Start-Job

    The Start-Job Cmdlet is a fast and extremely simple means of spawning asynchronous threads. Why do we care? Because performing parallel work is faster and our time is important. If I want to inventory the Windows services running on every server in my company, I don’t want to wait for each one to return data, […]

  • QS-Config v2.0 coming soon

    QS-Config v2.0 coming soon

    Years ago I found myself frustrated with the SQL Server installation wizard. I was working for an organization where SQL Server installs were needed regularly during points in their operational cycle and often they were not cookie cutter. Tweaks were necessary to many of their configurations and to say that I was overworked would be […]

  • Running PowerShell in a SQL Agent Job

    Running PowerShell in a SQL Agent Job

    When creating a SQL Agent Job to execute a PowerShell script, you have to decide which way that you want the PowerShell to run. Depending upon which version of SQL Server that you are using and which job step type that you choose, you might be running in different versions of PowerShell with different execution policies. I […]

  • PowerShell Profile Tips

    Automation is one of the purposes for using PowerShell. Automation is a funny thing, however. You can perform steps of automation almost to infinity. If you write a function that replaces 200 lines of code with 1 function call, that’s great. When using that function you find yourself typing out the full function name and […]

  • Start and Save Hyper-V VMs with PowerShell

    I use Windows 8 or Windows Server 2012 R2 on most of my local workstations between home and work. In order to conserve memory, I turn my Hypver-V lab environments on and off as I need them. Given that my smallest environment is a grouping of five virtual machines (VMs), I quickly got tired of […]

  • Availability Group fail-over test with PowerShell

    I have a number of SQL Server Availability Groups in my organization. Of them, most are multi-site configurations for disaster recovery. Naturally, the latency that a separate data center implies is more than my application can handle for its writes. For this reason, we use asynchronous commit with manual fail-over. We also conduct regular fail-over […]