You are here


PowerShell - Getting All Running SQL Services

Getting all SQL Server services running on a server using PowerShell:

PowerShell - Making Arrays

The basics of creating a PowerShell array and working with it.

PowerShell - Find Active Node On Cluster

PowerShell script that prints out the state of the node you are on - Active or Passive.

PowerShell - Query Database Remotely

The basic syntax for sending a query to SQL Server using PowerShell.

WMI and PowerShell (Video)

PowerShell - Get Boot Time of Computer

Show Date/Time Of Last Boot

​Get-WmiObject -class Win32_OperatingSystem | Select-Object __SERVER,@{label='LastBootUpTime';expression={$_.ConvertToDateTime($_.LastBootUpTime)}}

PowerShell - Scripts Not Allowed To Run

If PowerShell is not allowing you to run scripts then you might need to set the execution policy.
Set-ExecutionPolicy RemoteSigned

PowerShell - Get All SQL Server Instances In Environment

import-module failoverclusters
Import-Module -Name SQLPS -DisableNameChecking

$servers = "comma","separated","server","list"

foreach($server in $servers)
    $virtual_name = $server;
    $instances = '';
    $virtual_name = ((get-clusterresource -Cluster $server -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | 
                        get-clusterparameter VirtualServerName -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | 

PowerShell - Fast Ping


This is a very fast way to ping a server using PowerShell.

PowerShell - Get SQL Server Info

$assemblylist = 
"Microsoft.SqlServer.Dmf ",
"Microsoft.SqlServer.Instapi ",
"Microsoft.SqlServer.SqlWmiManagement ",
"Microsoft.SqlServer.ConnectionInfo ",
"Microsoft.SqlServer.SmoExtended ",
"Microsoft.SqlServer.SqlTDiagM ",
"Microsoft.SqlServer.SString ",
"Microsoft.SqlServer.Management.RegisteredServers ",
"Microsoft.SqlServer.Management.Sdk.Sfc ",
"Microsoft.SqlServer.SqlEnum ",
"Microsoft.SqlServer.RegSvrEnum ",
"Microsoft.SqlServer.WmiEnum ",
"Microsoft.SqlServer.ServiceBrokerEnum ",


This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
5 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer