Posted on September 5, 2009, 5:21 pm, by Rhys, under
Powershell.
With Powershell and SMO you can easily discover SQL Server instances running on your network in just a few lines of code. ?View Code POWERSHELL[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null; $smoObj = [Microsoft.SqlServer.Management.Smo.SmoApplication]; # This gets the sql servers available $sql = $smoObj::EnumAvailableSqlServers($false) foreach($sqlserver in $sql) { Write-Host -ForegroundColor Green "Discovered sql server: " $sqlserver.Name; } [...]
Posted on August 24, 2009, 12:24 pm, by Rhys, under
Powershell.
Powershell is really useful for documenting and managing your servers but it’s also a pretty good tool for working with data. I’ve been using it to merge csv files, with an identical structure, into a single file. Now this is pretty easy, if rather tedious, to do using SQL Server Import / Export functionality or [...]
Posted on July 29, 2009, 4:24 pm, by Rhys, under
Powershell.
I had a task to do today that required me to get all the names in a directory of files into a database. This seemed like a ideal job for Powershell and I’ve posted the (very simple) script here. There’s a few variables you need to change to fit your environment; $directory – this should [...]
Posted on July 6, 2009, 3:47 pm, by Rhys, under
Powershell.
In a previous post I provided a few small Powershell code blocks suitable for beginners to digest. Here are a few more that anyone starting with Powershell might like to experiment with. A simple For Loop in Powershell Here’s just a simple for loop in Powershell. ?View Code POWERSHELL# A simple for loop for($i = [...]
Posted on June 25, 2009, 8:20 pm, by Rhys, under
Powershell.
Checking for failed SQL Agent jobs should be part of any DBA workplan. Here’s another Powershell script that makes checking the last run outcome easy on multiple SQL Servers. To run this script you need to create a list of your SQL Servers in a text file called sqlservers.txt. Place this text file in your [...]
Posted on June 24, 2009, 6:52 pm, by Rhys, under
Powershell.
Here’s a Powershell script that can ping all computers that are in your domain. All computers registered in AD will be pinged, including ones long dead, so this script may be useful for figuring out what is still active on your network. There’s nothing to configure on this script so it should be good to [...]
Posted on June 19, 2009, 12:56 pm, by Rhys, under
Powershell.
Need to monitor disk space on multiple servers? Then make the job easy with this Powershell script. To configure this script just create a file called serverlist.txt in your user profile folder, C:\Users\Rhys on my laptop. The $percentWarning variable allows you to control at what percentage level you will be warned about free disk space. [...]
Posted on June 17, 2009, 6:57 pm, by Rhys, under
DBA,
Powershell.
I’ve been thinking about how Powershell can be used by the DBA as an extra tool in their armoury. An article that caught my eye was The Daily DBA Checklist, specifically an item about Triggers; "…last week some idiot turned a host of triggers off in our ERP system, causing a cascade of posting problems [...]
Posted on June 6, 2009, 1:48 pm, by Rhys, under
Powershell.
I previously posted an article explaining how to audit your SQL Servers with Powershell. In this article I wrote SMO properties to csv files. As there are a large number of properties you may be unsure of which ones you may need in the future. Luckily Powershell doesn’t make us fetch every single property manually; [...]
Posted on May 29, 2009, 7:44 am, by Rhys, under
Powershell.
Being able to know the setup and configuration of your SQL Servers is important for many IT Professionals. Powershell, combined with SMO, makes this task easy. SMO exposes a lot of properties allowing you to easily retrieve things like Processor & RAM Information, Service Pack Level, Operating System information, Collation Settings, number of Databases, and [...]