A new quota with a threshold value is not created, if there are threshold properties, commands

Konstantin 6 Reputation points
2022-09-27T20:34:27.23+00:00

Hi!
Tested on Windows Server 2019 Standard.

The example is taken from here https://video2.skills-academy.com/en-us/powershell/module/fileserverresourcemanager/new-fsrmquota?view=windowsserver2022-ps only the folder for which the quota is created has been replaced.
PS C:\Windows\system32> $Action = New-FsrmAction -Type Command -Command "c:\windows\system32\cmd.exe" -CommandParameters "echo [source file path] >> c:\log.txt" - ShouldLogError
$Threshold = New-FsrmQuotaThreshold -Percentage 90 -Action $action
New-FsrmQuota -Path "D:\Test" -Size 128MB -Threshold $Threshold -SoftLimit
New-FsrmQuota : 0x80070057, Parameter specified incorrectly.
string:3 character:1

  • New-FsrmQuota -Path "D:\Test" -Size 128MB -Threshold $Threshold -Soft ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidArgument: (MSFT_FSRMQuota:Root/Microsoft/.../MSFT_FSRMQuota) [New-FsrmQuota], CimExcept
    ion
  • FullyQualifiedErrorId : MI RESULT 4,New-FsrmQuota

The D:\Test folder exists. If you create from graph. interface, everything is perfectly created. From Powershell works if there are no threshold properties. Can you tell me what needs to be fixed to make it work?

Windows Server Storage
Windows Server Storage
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Storage: The hardware and software system used to retain data for subsequent retrieval.
642 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Weinrich, Kevin 0 Reputation points
    2023-08-23T15:20:22.9166667+00:00

    I figured it out! Here was my process: Since I could create the Action/Threshold via the GUI but not via PowerShell, I had the bright idea to use PS to compare the working Action I created via the GUI vs. the failed Action I created via PS. When I did that, I noticed the following differences:

    KillTimeOut, SecurityLevel, and RunLimitInterval. It turns out the PS defaults for SecurityLevel and KillTimeout don't work. So you need to add " -SecurityLevel LocalService -KillTimeout 0" or similar to the New-FsrmAction to get it to work.

    Here's the good Action:

    Body              :
    Command           : c:\windows\system32\windowspowershell\v1.0\powershell.exe
    CommandParameters : .\Send-FSRMEmail.ps1 -QuotaSystemPath '[Quota System Path]' -SourceFileRemotePaths '[Source File Remote
                        Paths]'
    EventType         : None
    KillTimeOut       : 0
    MailBCC           :
    MailCC            :
    MailTo            :
    ReportTypes       :
    RunLimitInterval  : 60
    SecurityLevel     : LocalService
    ShouldLogError    : True
    Subject           :
    Type              : Command
    WorkingDirectory  : D:\Scripts
    PSComputerName    :
    
    
    
    0 comments No comments