Here are my codes, $var.droppath
is a valid network space path, I've test it.
$map3 = new-PSDrive -name droppath -psprovider FileSystem -root $var.droppath
Then I ran
Get-PSDrive | ?{$_.Name -match "droppath"} | FT -AutoSize
and got the result:
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
droppath FileSystem \\network\sharespace\test1
Why used space and free space are empty? Is that means get-psdrive can not mapping network space or I made some mistake?
the Get-PSDrive tool only returns Free and Used information for providers that have that information available. Oddly enough, PS doesn't make that easy to get for the PS-Drives simply because it is really and alias that MIGHT map to something that doesn't have that info. PS-drives only survive the session so they aren't full OS level mappings. Thus you don't get OS level information like the remote space free.
The easy work-around is to use
net use
and map it to a real drive letter. Don't forget to tear it back down when you are done.UPDATE I left out this link: query different free share spaces by powershell, but every time got the same result which has some example code to do the mapping from PS and get the data you need manually.
Mark is correct, but looking at the TechNet article on Get-PSDrive here, you can see that by using get-wmiobject and the win32_logicaldisk class you can get free space and total space pretty easily.