PowerShell SQL Server Agent Uses Version 2

Just as an FYI so there is no confusion: If you intend to use the PowerShell module packaged with SQL Server Agent 8, 12, 14, or 16, you must be aware it uses its own version of PowerShell regardless of the version you have installed! This can be very confusing if you use Cmdlets which require PS Version 3 and above.

Take a look at the two images below. The first sets up a PowerShell “type” job which only includes the command to display the current PowerShell version (i.e. $PsVersionTable.PsVersion). The second shows the job result form Job History. You can clearly see the PowerShell version used I version 2. Yet, I do have PowerShell version 5 installed on my PC . The version of SSMS I am using is 2016. The SQL Server I am referencing is 2008r2. However, you get the same result with SQL Server 2008 through 2016.


SQL Agent POSH V 2

Leave a Reply