Archive for the ‘Powershell’ Category

Check the value of an Environmental Variable on Multiple servers

Warning: count(): Parameter must be an array or an object that implements Countable in /home/fbsqlcom/public_html/ on line 31

Here’s one powershell method for how to check the value of an environment variable on multiple servers; ?View Code POWERSHELL$computers = @("server1", "server2", "server3");   foreach ($c in $computers) { Get-WmiObject -ComputerName $c -Class Win32_Environment -Filter "Username = ‘<SYSTEM>’ AND Name = ‘VAR_NAME’"; } Output will be similar to below… VariableValue Name UserName ————- —- […]

What’s protected from accidental deletion in Active Directory?

Here’s just a little tip I picked up from a presentation by Mark Broadbent (retracement on twitter). I’m the guy who wasn’t listening! Mark stressed the importance of enabling the Protection from accidental deletion property in active directory for your Failover Clusters. Here’s how to check this for Computers with Powershell. This string of commands […]

Failover Cluster Report post on Scripting Guys

I’ve got another post on the Scripting Guys Blog. This post uses powershell to report on a Windows Failover Cluster. I think it’s pretty cool, let me know what you think!.

Matching windows cluster node ID to physical server

Here’s the Powershell version of matching the node number in Cluster.Log files to the actual cluster node names. Essentially log messages like this one… ERROR_CLUSTER_GROUP_MOVING(5908)’ because of ”Cluster Disk’ is owned by node 1, not 2.’ Inspired by this post using cluster.exe. ?View Code POWERSHELLGet-ClusterNode -Cluster ClusterName | SELECT Name, Id, State | Format-Table -Autosize; […]

List AD Groups Setup on SQL Server

Here’s a quick powershell snippet to display the Windows groups setup as logins on SQL Server. ?View Code POWERSHELLImport-Module SQLPS -DisableNameChecking -ErrorAction Ignore; Import-Module ActiveDirectory -DisableNameChecking -ErrorAction Ignore; $sql_server = "sql_instance"; $srv = New-Object Microsoft.SqlServer.Management.Smo.Server $sql_server; $srv.Logins | Where-Object {$_.LoginType -eq "WindowsGroup";}; Output will be similar to below. Name Login Type Created —- ———- ——- […]