Syphirint Syphirint - 5 months ago 48
PowerShell Question

PowerShell - Error in path while Set-FsrmQuota

I'm trying to make a script that changes the quota of a specific directory on a remote server. For that I'm using the following code (

enter as parameters):

$prefix_path = "C:\Shares\Users\";
$path = $prefix_path + $chosen_username;

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."

And it is giving me this error:

Cannot bind argument to parameter 'Path' because it is an empty string.
+ CategoryInfo : InvalidData: (:) [Set-FsrmQuota], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Set-FsrmQuota
+ PSComputerName : ServerName

I've done debug and the value of
is correct.


when using invoke-command on a remote computer, the local variables are unknown for the remote host, so you have to use either

  • the using prefix for PS >= 3 invoke-command -computername $servername {Set-FsrmQuota -path $using:path -Size $using:Quota+"GB"}

  • the argumentlist parameter for PS < 3 invoke-command -computername $servername {Set-FsrmQuota -path $args[0] -Size $args[1]+"GB"} -argumentlist $path,$quota