locked
Excel Server Management Script - Free Disk Space RRS feed

  • Question

  • Hi,

     

     I use an Excel 2010/2013 sheet to manage my 2008R2 terminal servers. To have a look at this servers, I wrote a script to determine some information of the servers. That works pretty well. Now I want to get to know how much free space the local disk has.
     Usually no problem. I have to connect to WMI via

    GetObject("winmgmts:" & _            "{authenticationLevel=pktPrivacy}!\\" & _            strComputer & "\root\cimv2\TerminalServices")

         


    and take information of the Win32_LogicalDisk class.
     But I can't use this kind of connection. I want to connect via

    objwbemLocator.ConnectServer(strComputer, strNamespace, strComputer & "\" & strUser, strPassword)


    because my user account has no admin rights on the server.
     Unfortunately the selection of the class returns an invalid class to the variable, so I can't read the free space.
     My selection looks like

    Set colItems = objWMIService.ExecQuery _                ("Select * from Win32_LogicalDisk")


    I also tried to get the C-drive directly, but always the same problem. No error message, but the content of colItems a invalid class.
     It works great with the WMI connection without user authentification.
     What can I do, to get this working? Do you need any other code information? My other selection works:

    Set colItems = objWMIService.ExecQuery _                ("Select * from Win32_TerminalServiceSetting")


    Thank you for your help.

    Tuesday, September 16, 2014 7:41 AM

Answers

  • Did you had a change to look at below link, it seems to have all the necessary code to do exactly what you are after.

    VBScript to Check Disk Space Availability

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    Please vote an answer helpful if they helped. Please mark an answer(s) as an answer when your question is being answered.

    • Marked as answer by hans_wurst123 Tuesday, September 23, 2014 7:21 AM
    Thursday, September 18, 2014 5:28 PM

All replies

  • Did you had a change to look at below link, it seems to have all the necessary code to do exactly what you are after.

    VBScript to Check Disk Space Availability

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    Please vote an answer helpful if they helped. Please mark an answer(s) as an answer when your question is being answered.

    • Marked as answer by hans_wurst123 Tuesday, September 23, 2014 7:21 AM
    Thursday, September 18, 2014 5:28 PM
  • Hello,

    I made a mistake. In my script I am checking for the TS drain mode. To find the free space on the same server, I wanted to use this connection. Unfortunately that is not the same namespace ("\root\cimv2\TerminalServices" for drain mode, "\root\cimv2\" for free space), so I got the mentioned error getting an invalid class when I select Win32_LogicalDisk.

    Thank you for your help.

    Tuesday, September 23, 2014 7:21 AM