PowerShell With Uptime – Getting Days Only


There is a handy and free tool to check your system’s uptime called “Uptime”.  (Clever, no?)  It can be downloaded at http://uptimeexe.codeplex.com. While it is very easy to use (just navigate to it in a command window and type “uptime”), it doesn’t give much of an option for formatting the output to include only the days.  So, a […]

Discover How User Is Accessing SQL Instance (PowerShell and T-SQL)


When your security gets unruly, it can get time consuming to figure out how a user is accessing a SQL instance. Sometimes you may know that a user is getting access via one certain AD group but you aren’t sure if any other groups are granting access. Furthermore, a user might be in a group […]

PowerShell With Uptime – Getting Days Only


There is a handy and free tool to check your system's uptime called "Uptime".  (Clever, no?)  It can be downloaded at http://uptimeexe.codeplex.com. While it is very easy to use (just navigate to it in a command window and type "uptime"), it doesn't give much of an option for formatting the output to include only the days.  So, a […]

Generate Red Gate MultiScript .dat File


This is a PowerShell script that puts out the XML required to update your Red Gate MultiScript servers.  Manually entering the SQL instances from within the application can be a daunting task if you have a large number to do.  This script will have you up and running in seconds. You must first have a […]

PowerShell – Get All SQL Instances On Server


This script will return all SQL instances running on a server or list of servers. cls Import-Module -Name SQLPS -DisableNameChecking $servers = “SERVER_NAME”, “SERVER_NAME_2”, “ETC”; foreach($server in $servers) { $path = “SQLServer:\SQL\” + $server; $instances = Get-ChildItem -Path $path; $instances; }

PowerShell – Get “Logon As” Information From Remote (or local) Server


This was made possible by the Scripting Guy.  I have boiled it down to the answer. If you want to use PowerShell to query for the log on account that normally is displayed in the services.msc service properties window:   Here is the PowerShell script:   $server_name = "name_of_server"; $services = Get-WmiObject win32_service -ComputerName $server_name […]

Restore All Databases With Most Recent Backup


This is a bit of a scary task.  Someone tells you about 87 databases that all need to be restored from the most recent FULL backups. You can either spend the rest of your day pointing and clicking, or you can use some PowerShell power to crank out the script and get on with your […]