mani@123 (1/22/2013)
SERVER2008:declare @svrName varchar(255)
declare @sql varchar(400)
--by default it will take the current server name, we can the set the server name as well
set @svrName = @@SERVERNAME
[font="Arial Black"]set @sql = 'powershell.exe [/font]-c "Get-WmiObject -Class Win32_Volume -Filter ''DriveType = 3'' | select name,capacity,freespace | foreach{$_.name+''|''+$_.capacity/1048576+''%''+$_.freespace/1048576+''*''}"'
--creating a temporary table
CREATE TABLE #output
(line varchar(255))
--inserting disk name, total space and free space value in to temporary table
insert #output
[font="Arial Black"]EXEC xp_cmdshell @sql[/font]
+10000000000000000000000 Mani!!! I absolutely freakin' love it! 🙂 I was starting to think I was the only one in the world that did that!
--Jeff Moden
Change is inevitable... Change for the better is not.