【发布时间】:2016-08-04 17:12:30
【问题描述】:
我正在尝试编写一个脚本来更改远程服务器上特定目录的配额。为此,我使用以下代码($Quota 和 $chosen_username 作为参数输入):
$prefix_path = "C:\Shares\Users\";
$path = $prefix_path + $chosen_username;
if($Quota){
invoke-command -computername $servername {Set-FsrmQuota -path $path -Size $Quota+"GB"}
}
if((invoke-command -computername $servername {Get-FsrmQuota -path $path} | select @{n='QuotaSize'; e={$_.Size / 1gb -as [int]}}).QuotaSize -eq $Quota){
return "Success."
} else {
return "Failed."
}
它给了我这个错误:
Cannot bind argument to parameter 'Path' because it is an empty string.
+ CategoryInfo : InvalidData: (:) [Set-FsrmQuota], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Set-FsrmQuota
+ PSComputerName : ServerName
我已经调试过了,$path 的值是正确的。
【问题讨论】:
-
这里有错字:
$path = $prefixo_path+$chosen_username($prefix o _path) ? -
在这种情况下,是的,因为我正在翻译成英文,对不起。但在代码中是正确的。
标签: powershell fileserver