1

I am using sp 2013. I try to create a new qoata template but still got this error:

System.Management.Automation.SetValueInvocationException: Exception setting "StorageWarningLevel": "Specified argument was out of the range of valid values. Parameter name: Warning storage level must be an integer that is greater than or equal to 0 and less than the maximum storage level." ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: Warning storage level must be an integer that is greater than or equal to 0 and less than the maximum storage level. at Microsoft.SharePoint.Administration.SPQuota.set_StorageWarningLevel(Int64 value) at CallSite.Target(Closure , CallSite , Object , Int64 )
--- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(Boolean createLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.<>c__DisplayClass4.b__2() at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action) at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args) at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args) at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()

This is my powershell script:

Write-Host "Template not found, creating..." -NoNewline

        $quota = New-Object Microsoft.SharePoint.Administration.SPQuotaTemplate
        $quota.Name = $name
        $quota.StorageMaximumLevel = 20971520
        $quota.StorageWarningLevel = 5242880
        $quota.UserCodeWarningLevel = 100
        $quota.UserCodeMaximumLevel = 300

        $script:contentService.QuotaTemplates.Add($Quota)
        $script:contentService.Update()

        $result = 0
        Write-Host "Done" -ForegroundColor Green

what is going wrong?

1

First, reference the web service, which is missing. Second, add the UserCodeMaximumLevel before you add the UserCodeWarningLevel. Third, add the new quota using the web service.

if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"} 
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$webService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService 

$quota=New-Object Microsoft.SharePoint.Administration.SPQuotaTemplate
$quota.Name = "MyQuota"
$quota.StorageMaximumLevel = 20971520
$quota.StorageWarningLevel = 5242880
$quota.UserCodeMaximumLevel = 300
$quota.UserCodeWarningLevel = 100

$webService.QuotaTemplates.Add($quota)
0

Was the quota template actually created? If yes, then the error can be ignored.

It is possible that Sharepoint will throw an error:"Warning storage level must be an integer that is greater than 0 and less than the maximum storage level". As this error is thrown by SharePoint, not SharePoint Provider, it can not be modified. The error message can be safely ignored if is set to be non-negative integer.

From here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.