I'm trying to eventually create a winform powershell tool that manages disk quotas on a Windows 2016 server from a Windows 10 client workstation. Given that Every single user has at least 2 mapped drives is there any way to query a specific user and volume without get-wmiobject cycling through every single quota first? The goal is to create a tool as fast or faster than just remoting into the file server to increase quotas as requests come in but to increase a quota we need to know the quota limit first.
I also know that I could map the root of a drive to a letter using my admin creds, but we don't allow saving credentials for mapped drives because we have to follow guidelines set up by federal government (State Health Care Agency) and our security team doesn't allow for credentials to be saved in any kind of windows logon. So that being said the powers that be are wanting me to find a way around us remoting into the server with our admin credentials and increasing quotas.
We don't use FSRM on the server but instead manage quotas for each volume. That decision was made before my time.
For testing I have tried using the following:
$query = "Select * from win32_diskquota where QuotaVolume=""Win32_LogicalDisk.DeviceID='$volume'"" AND User =""Win32_Account.Domain='$domain',Name='$Username'"""
Get-WmiObject -Query $query -ComputerName server
This one I knew was going to take forever, but tried it anyway:
Get-WMIObject Win32_DiskQuota -ComputerName $computer | where {$_.deviceid -eq "Win32_LogicalDisk.DeviceID=$drive" -and $_.user -eq "Win32_Account.Domain=$Domain"+",Name=$name"}
I've also used get-ciminstance just to see if it would compile the list of quotas from the remote server any faster, but no dice.
Any suggestions, hints, or advice would be great. Thanks in advance.