locked
Drive size information RRS feed

  • Question

  • Hi Guys,

    I am running the below script from my pc and I am getting the below error please can you help.

    • ##connect-QADService -service 'domain.local' -Credential (Get-Credential Domain\Account)
      $servers = Get-Content "D:\Server Info\domain.txt"
      $DriveSize = foreach($server in $servers){
      Get-WMIObject Win32_LogicalDisk -filter DriveType=3 -computer $server| Select SystemName,DeviceID,VolumeName,@{Name=”Size(GB)”;Expression={[decimal](“{0:N1}” -f($_.size/1gb))}},@{Name=”Used Space(GB)”;Expression={[decimal](“{0:N1}” -f(($_.size/1gb)-($_.freespace/1gb)))}},@{Name=”FreeSpace(GB)”;expression={[decimal]::round(($_.FreeSpace/1073741824),2)}},@{Name=”Used Space(%)”;Expression={“{0:P2}” -f((($_.size/1gb) – ($_.freespace/1gb)) / ($_.size/1gb))}}
      }
      $DriveSize | Export-CSV -Path "D:\Server Info\domain.csv” -NoTypeInformation

    Error Message

    Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)

    This is the root domain where i am getting this msg, however running the same script on a child domain is absolutely fine.

    The account I am using has enterprise admin rights. Now I am lost where I am getting it wrong.

    Please note that root domain DC's have windows 2003 server and no 2008 server.

    Anyone please help.

    Many Thanks,

    Ali


    Ali Hussaini

    Tuesday, December 2, 2014 3:00 PM

Answers

  • I have resolved it added my child domain account to the root domain Administrators group and it worked.

    Ali Hussaini

    • Marked as answer by DemoPower Tuesday, December 2, 2014 3:28 PM
    Tuesday, December 2, 2014 3:28 PM

All replies

  • I have resolved it added my child domain account to the root domain Administrators group and it worked.

    Ali Hussaini

    • Marked as answer by DemoPower Tuesday, December 2, 2014 3:28 PM
    Tuesday, December 2, 2014 3:28 PM
  • There is no WMI on a root domain.  You are querying servers. One of the servers has your account blocked or does not have the WMI set up for remoting.

    This is what you are erring on:

    Get-WMIObject Win32_LogicalDisk -filter DriveType=3 -computer $server

    The error message contains the server name that failed.  YOu didn't post the whole error so we cannot help you.


    ¯\_(ツ)_/¯

    Tuesday, December 2, 2014 4:08 PM