スクリプトまたはコマンドを使用してリモートドライブのクォータを設定するにはどうすればいいですか

スクリプトまたはコマンドを使用してリモートドライブのクォータを設定するにはどうすればいいですか

すべての共有をマウントするための 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 を使用していると想定しました。リモート ドライブではこれを行うことはできません。データをホストしているファイル サーバーで実行する必要があります。

関連情報