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 that's nested in another group, through which they are gaining access to your SQL instance.
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 simple workaround is to use some "replace" commands within PowerShell and only output the number of days. Here's how:
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 comma-separated list of your instances to load into the array. Once you have that, set $instances equal to your list. Notice that the .dat file will launch in Notepad to make it easy to paste in the results. Then, save the file and you're done.
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 day. Here is the PowerShell way.
I don't like to fire-off the actual backups from PowerShell, rather I just use it to script out the restore script. So, this PowerShell script will output the T-SQL restore script:
Maybe this is a one-off type of thing, but if you need to see every folder within a directory and get the list of who can access that folder, it can be done using PowerShell. The output is tab-separated and can easily paste into an Excel sheet.