Hello Tim,
Thank you for your question and for reaching out with your question today.
If the Get-PSDrive and WMI queries are not showing accurate values for free space on a network share with user quotas configured, you can try using the Get-SmbShare cmdlet in PowerShell to retrieve the correct free space information. Here's an example:
$sharePath = "\\server\share" # Replace with the path to your network share
$share = Get-SmbShare -Name $sharePath
if ($share) {
$freeSpace = $share.FreeSpace
Write-Host "Free space on $sharePath: $freeSpace bytes"
}
else {
Write-Host "Failed to retrieve information for $sharePath"
}
The Get-SmbShare cmdlet specifically retrieves information about SMB shares, including their free space. It should provide more accurate results compared to Get-PSDrive and WMI queries.
Note that the Get-SmbShare cmdlet requires PowerShell version 3.0 or later and must be run with administrative privileges. Ensure that you have the necessary permissions to access the network share and retrieve the share information.
If the issue persists or the Get-SmbShare cmdlet doesn't provide the expected results, it's possible that the user quota configuration with File Service Resource Management is causing discrepancies in the reported free space. In such cases, you may need to explore alternative methods, such as using .NET classes or APIs, to retrieve the free space information directly from the underlying file system.
I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.
If the reply was helpful, please don’t forget to upvote or accept as answer.