Recently I needed to check which of our databases, on our many SQL Servers, had the TRUSTWORTHY property set to true. This property, when set to false, can reduce certain threats from malicious assemblies or modules. Obviously this should only be enabled where it needs to be. Here’s a quick Powershell script that will enable [...]
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 [...]
I’m currently building a CMDB at work and I wanted to include a bit of performance data in the information collected. The data cache is probably the biggest consumer of memory within SQL Server so It makes sense to collect this for future analysis. As a start I’m gathering the amount of space each database [...]
Posted on August 10, 2010, 8:10 pm, by Rhys, under
Powershell.
A reader commented on a previous post pointing out a deficiency in one of the scripts used to kill processes on remote computers. If more than one instance of the specified process was running on the target computer the script would buckle. This is pretty easy to rectify. The below script will kill all process [...]
Posted on April 11, 2010, 3:50 pm, by Rhys, under
DBA,
Powershell.
Sometimes it’s useful to get a quick overview of what objects are referencing a particular table, view or function. This may arise when we think we may need to drop an object but want to double-check if anything in the database is still referencing it. Here’s a quick solution in the form of a Powershell [...]
Posted on March 30, 2010, 9:29 pm, by Rhys, under
Powershell.
After the recent change in our clocks due to BST I noticed that one of our servers was a hour slow. I wanted to check the rest since we run a lot of time dependant processes. Now we have Powershell any thought of manually checking each one is madness. Here’s a quick script I knocked [...]
Posted on March 27, 2010, 6:57 pm, by Rhys, under
DBA,
Powershell.
Here’s neat little Powershell script you can use to audit your SQL Server databases. The script is dependant on the SQL Browser service, to discover instances, so you will need to make sure this is running. This will allow you to audit all SQL Server instances on the localhost with details of your databases and [...]
Posted on February 27, 2010, 7:18 pm, by Rhys, under
Data,
Powershell.
The London Datastore has loads of datasets available that we can use for free. One of the datasets available is a list of TFL Station Locations. The station location feed is a geo-coded KML feed of most of London Underground, DLR and London Overground stations. Here’s Powershell script that will extract this data from a [...]