Quantcast
Channel: SQL Server
Viewing all articles
Browse latest Browse all 3819

Blog Post: PowerShell – Identify and switch between installed PowerShell Versions

$
0
0
Most of the time we have been used to cmdlets and it’s various features but do not know about the version and hence this post might help some of you to understand in find ing different versions of PowerShell and how to switch between versions (provided multiple versions are installed on your Machine). I’m using Where clause syntax to explain version switching. Code to find version- PS:\ Get-Host | Select-Object Version Version ——- 2.0 PS:\ $Host.Version Major  Minor  Build   Revision —–    —–    —–    ——– 2        0         -1      -1 PS:\ $PSVersionTable.PSVersion Major  Minor  Build   Revision —–    —–    —–    ——– 3        0         -1      -1 Switch between versions - Goto Cmd Prompt and type the below command C:\ Powershell -version 2 PS C:\ Get-Host | select Version #v2 syntax PS C:\ Get-Service | Where {$_.name -like “*SQL*”} Status       Name                              DisplayName ——          —-                                 ———– Stopped   MSSQL$MICROSOFT…  Windows Internal Database (MICROSOF… Running   SQLWriter                       SQL Server VSS Writer PS C:\ Get-Service | where name -like “*SQL*” Error Message - where : Cannot bind parameter ‘FilterScript’. Cannot convert the “name” value of type “System.String” to type “System.Management.Automation.ScriptBlock”. C:\ powershell -version 3 PS C:\ Get-Host | Select Version PS C:\ Get-Service | where {$_.name -like “*SQL*”} Status       Name                              DisplayName ——          —-                                 ———– Stopped   MSSQL$MICROSOFT…  Windows Internal Database (MICROSOF… Running   SQLWriter                       SQL Server VSS Writer #v3 syntax PS C:\ Get-Service | Where name -like “*SQL*” Status       Name                              DisplayName ——          —-                                 ———– Stopped   MSSQL$MICROSOFT…  Windows Internal Database (MICROSOF… Running   SQLWriter                       SQL Server VSS Writer Syntax for Where-Object V2 Syntax : Where-Object { $_. property name } V3 Syntax : Where-Object property name #Supports V2 syntax

Viewing all articles
Browse latest Browse all 3819

Trending Articles