You are here

powershell

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
https://technet.microsoft.com/en-us/library/ee176961.aspx

PowerShell - Fast Ping

Source: https://gist.github.com/mbrownnycnyc/9913361

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

PowerShell - Get SQL Server Info

$assemblylist = 
"Microsoft.SqlServer.Management.Common",
"Microsoft.SqlServer.Smo",
"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 ",

PowerShell - Replace All Instances Of Something In All Files In Directory

This script searches every file in a directory for a particular string and replaces it with another value.
get-childItem  | ForEach { (Get-Content $_ | ForEach {$_ -replace "OLDVALUE,"NEWVALUE"}) | Set-Content $_}

Pages

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
11 + 9 =
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