Posted on June 29, 2011, 11:02 am, by Rhys, under
DBA,
Powershell.
It’s considered a bad practice Not using Primary Keys and Clustered Indexes here’s a Powershell script that can make checking a database for this very easy. Just set the $server to the sql instance you want to check and $database as appropriate. ?View Code POWERSHELL# variables $server = "sqlinstance"; $database = "badDB"; # Load SMO [...]
Posted on May 25, 2011, 10:17 pm, by Rhys, under
Powershell.
Each new cmdlet I discover makes me fall in love with Powershell a little bit more. A while ago I discovered the Compare-Object cmdlet. The examples given in the documentation demonstrate how to compare computer processes and text files but I was interested to see if this would work with a dataset. So I tried [...]
Posted on February 21, 2011, 9:21 pm, by Rhys, under
Powershell.
I was recently asked for a list providing size details of all the database and transaction log backups we take for SQL Server. Along with this I was asked to provide the approximate daily backup size. Since I’m no fan of trawling through folders, ordering by date modified, and then viewing properties to get the [...]
Posted on February 1, 2011, 8:50 pm, by Rhys, under
Powershell.
Here’s a few of the keyboard shortcuts for Powershell I always find myself using during the day at work. Pause output on the screen Sometimes a command may produce lots of output causing the screen to scroll rapidly. Pressing Control & S will pause the output currently on the screen. Press any key to continue [...]
Posted on December 21, 2010, 9:37 pm, by Rhys, under
Powershell.
Sometimes I’m writing Powershell scripts to gather information on a seemingly ad-hoc basis and then someone says; "Oh, and can you send that to me in an email every day|week|month". These scripts would often use a bunch of Write-Host statements to output to the console. Modifying these to send the output in an email can [...]
Posted on December 15, 2010, 9:17 am, by Rhys, under
Powershell.
I’ve written a post about Documenting Databases with Powershell that’s featured today on the Microsoft Scripting Guys blog. Head on over and check it out!
Posted on December 1, 2010, 9:17 pm, by Rhys, under
Powershell.
I’ve been working on a performance benchmarking project recently to gauge the effect of new releases to our systems. Powershell happens to be very useful gathering various system statistics using the Get-Counter cmdlet. There’s literally a tonne of available counters for everything to disk use, memory usage to sql server specific counters. You can list [...]
Posted on October 27, 2010, 8:03 pm, by Rhys, under
Powershell.
There’s two methods I often use for sending email in my Powershell scripts. The first uses the Send-MailMessage cmdlet and the second resorts to using the .Net Framework. Why do I use two methods? Well…. ?View Code POWERSHELLSend-MailMessage -To ‘me@here.com’ -From ‘sender@here.com’ -Subject ‘Test Message’ -Body ‘This is a test message.’ -SmtpServer ‘smtp.server.com’; The Send-MailMessage [...]
Posted on October 21, 2010, 9:58 pm, by Rhys, under
Powershell.
Today I was reading the post Powershell is Really Easy… If you know what you’re doing and it really struck a chord with me. A few days ago I discovered the ConvertTo-HTML cmdlet that can easily convert Powershell objects into formatted html pages. As I’ve written a few scripts producing html output, by sticking together [...]
In a previous post I showed how you can collect information on what is held in the data cache. The data collected here was just a simple summary of how much space each database was consuming. While useful we will need more detailed information on what is inside the cache to get a proper handle [...]