locked
get volume of free disk space without WMI RRS feed

  • Question

  • Hi,

    I have a situation where there is a remote server which I only have a map drive access to.

    So the following command returns true:

    Test-Path -path $ServerName\C$

    But with this command I get access denied:

    $disk=Get-WmiObject win32_logicaldisk -ComputerName $ServerName -Filter "deviceid = 'C:'"

    My question is:

    Is there a way to get the info of a disk space via a mapped drive ?

    Thanks,

    Dani

    Wednesday, December 26, 2018 3:12 PM

All replies

  • You must be an administrator to use WMI.


    \_(ツ)_/

    Wednesday, December 26, 2018 4:01 PM
  • Thats what I am saying - please do not answer the obvious.

    Wednesday, December 26, 2018 5:53 PM
  • Please start by learning basic Windows technologies and learn basic PowerShell.  The only answer is that you must be an admin.  We cannot give you any way around that.

    There is no way to get disk space from a mapped drive.  You can only get the size of the files on the drive.   With some providers the free space will be visible in File Explorer but it will likely be incorrect.

    The availability of the free space value is a Windows issue and has nothing to do with PowerShell.  PowerShell can only do what the OS allows.


    \_(ツ)_/

    Wednesday, December 26, 2018 6:29 PM
  • stop answering my questions and giving me lectures of what to do or not.

    I think you are misleading.

    Wednesday, December 26, 2018 6:35 PM
  • If you're able to map a drive to the target, you can then use get-psdrive and look at the 'free' / 'Free (GB)' property.


    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    Wednesday, December 26, 2018 6:43 PM
  • What is it that you want.  We cannot run your system for you.  You must know enough of the basics of the technology to understand the answers.  If you do not care to learn this then you will need to hire a consultant to help you.


    \_(ツ)_/

    Wednesday, December 26, 2018 6:43 PM
  • If you're able to map a drive to the target, you can then use get-psdrive and look at the 'free' / 'Free (GB)' property.


    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    Which is unreliable based on the provider and system.  I have numerous W7 systems that report free space but it is off by 50% when queried via Get-PsDrive.


    \_(ツ)_/

    Wednesday, December 26, 2018 6:47 PM
  • Hi,

    Thanks for your question.

    Maybe you can try to add "-credential" parameter to use an administrator account to get $c information.

    $disk=Get-WmiObject win32_logicaldisk -ComputerName $ServerName -Filter "deviceid = 'C:'" -Credential (Get-Credential)

    Best Regards,

    Lee


    Just do it.

    Thursday, December 27, 2018 2:09 AM