Archive for the 'Powershell' Category

Disk information via PowerShell & WMI

December 12, 2008

Sorry for taking so much time off in between posts. Lot’s of stuff happening. So, without further waiting, here we go – the long-promised Disk Info via PowerShell & WMI.
Note, there is a filter being applied to Get-WMIObject ["Drive Type = 3"] is a local disk drive.

##Create ServerList.txt file:
sqlcmd /Lc > F:/temp/ServerList.txt

#Populate $Server_List
$Server_List [...]

Three scripts of mine at SQLServerCentral.com

June 12, 2008

Since I can’t publish them myself for thirty days (I did agree to the sites rules about re-publishing)…
Delete files older than N-days via T-SQL:
Script
Powershell “unload and archive table” script:
Script
SQL Server “Quick n dirty” Restore Generator:
Script

SMO & Connection Pooling (and how to avoid it).

June 12, 2008

First, I’d like to apologise for not being as active the last week or so. I caught some very nasty food poisining from a local restaraunt chain. I won’t give names but thier initials start with “Chipotles”. ;)
I’d like to discuss connection pooling with SMO…
In my process’ that I’ll be demonstrating with, [...]

SMO server based connection vs. “classic” — Take two.

May 28, 2008

It was pointed out to me today by the lead dev at work, that I can remove two more lines from the script.
I have to confess that I am rather new to object-oriented types of programming. PowerShell is really my first venture into the OO world via .NET. DataSet/Adapters are still a bit [...]

SMO server based connection vs. “classic”

May 27, 2008

Ok, I said I was going to show an easier way than the ‘classic’ way of connecting to a database server. You’ll be amazed at how much less code there actually is (or needs) for an SMO based connection.
Fire up your trusty PowerShell IDE (mine happens to be PowerGUI made by the folks over [...]

Powershell – Read list & get service information.

May 23, 2008

This is a PowerShell script that will use SQLCMD to generate a list of SQL Servers on your network, piping the reults into a file.  A “classic” database connection is made and the list is processed using a PSH foreach loop calling Get-WMI in order to retrieve SQL Service information via WMI. As the service information is [...]