powershell and SQL -


i working powershell , sql using query extract drive information server

i writing following query

set @sql = 'c:\windows\syswow64\windowspowershell\v1.0\powershell.exe -c "get-wmiobject -class win32_volume -filter ''drivetype = 3'' | select name,label,capacity,freespace | foreach{$_.name+''!''+$_.label+''|''+$_.capacity/1048576+''%''+$_.freespace/1048576+''*''}"'     xp_cmdshell @sql 

i following output

output

******************************************************************************************* c:\!riscdcc36n03c$|139980.3984375%35242.921875* d:\!riscdcc36n03d$|139977.99609375%34774.08984375* g:\!riscdcsql552g|92151.9375%46329.1875* m:\!|0%0* m:\riscdcsql557bmp\!riscdcsql557bmp|81911.9375%31869.3125* m:\riscdcsql557dmp\!riscdcsql557dmp|40954.9375%37753.5* m:\riscdcsql557cmp\!riscdcsql557cmp|20475.9375%7643.375* t:\!riscdcsql563t$|81911.9375%15462* r:\!riscdcsql561r$|35836.9375%19392.0625* p:\riscdcsql560bmp\!riscdcsql560bmp|225278.9375%15844.625* p:\!riscdcsql560p$|245759.9375%13014.75* p:\riscdcsql560cmp\!riscdcsql560cmp|122876.9375%29950.9375* p:\riscdcsql560amp\!riscdcsql560amp|102398.9375%100423.25* l:\!riscdcsql556l$|20479.9375%5072.1875* i:\!riscdcsql553i$|512003.9375%81162.5* i:\riscdcsql553mp1\!riscdcsql553mp1|307200.9375%137322.9375* x:\riscdcsql567cmp\!riscdcsql567cmp|97288.9375%45540.125* x:\!|0%0* x:\riscdcsql567amp\!riscdcsql567amp|35841.9375%28526.125* u:\!riscdcsql564u$|66552.9375%7892* null   ************************************************************************** 

i don't understand why m drive , x drive giving 0%0. using information calculate further growth of space. while calculating givng me divide zero.

( docs http://msdn.microsoft.com/en-us/library/windows/desktop/aa394515%28v=vs.85%29.aspx )

it looks drive m , x each have full volume/partition (no free space) amongst others.

remove them output filter clause -
-filter ''drivetype = 3 , freespace>0''

that works me, in powershell prompt...

ps c:\windows\system32> get-wmiobject -class win32_volume -filter 'drivetype = 3 , freespace>0' | select name,label,capacity,freespace 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -