如何使用脚本或命令设置远程驱动器配额

如何使用脚本或命令设置远程驱动器配额

我们有一个 Windows 10 管理控制台来挂载所有共享。管理控制台已加入 AD 域。我们正在使用管理控制台中的文件资源管理器来设置用户磁盘配额。在设置用户磁盘配额之前,等待加载所有配额条目需要很长时间。那么,是否有任何脚本或命令行可以完成这项工作?

不幸的是,fsutil 实用程序仅适用于本地卷。

答案1

# Check if Fsrm module is installed
if (-not (Get-Module -ListAvailable -Name Fsrm)) {
    Write-Host "File Server Resource Manager module not installed. Please install it and run the script again."
    return
}
 # Import the File Server Resource Manager module
    Import-Module Fsrm
    
    # Specify the username and path to the folder you want to set quotas for
    $username = "JohnDoe"
    $folderPath = "C:\Users\$username\Documents"
    
    # Set the quota limit (in bytes)
    $quotaLimit = 500MB
    
    # Create a new quota
    New-FsrmQuota -Path $folderPath -UserName $username -Size $quotaLimit -Enforce
    
    # Optionally, you can set an email notification for the user
    Set-FsrmQuota -Path $folderPath -UserName $username -Notification $true -NotificationLimit $quotaLimit

如果你使用配额模板,则只需使用 PowerShell 分配模板即可

# Import the File Server Resource Manager module
Import-Module Fsrm

# Specify the username and path to the folder you want to set quotas for
$username = "JohnDoe"
$folderPath = "C:\Users\$username\Documents"

# Specify the name of the quota template
$quotaTemplateName = "StandardTemplate"

# Assign the quota template to the folder
Set-FsrmQuota -Path $folderPath -UserName $username -TemplateName $quotaTemplateName

我假设您使用 fsrm 来分配配额。您无法对远程驱动器执行此操作,这需要在托管数据的文件服务器上执行。

相关内容