title: setting CPU throttling per user on server 2012
body: <p>On server 2008 R2 i programatically set the CPU LIMIT to a certain percentage with the following PowerShell</p>
  
  <pre><code>function Set-UserAccountCPUThrottle
  {
  [CmdletBinding()]
  Param(
  [ValidateNotNullOrEmpty()]
  [parameter(Mandatory = $true)]
  $UserNameToRestrict,
  [Parameter(Mandatory = $false)]
  [int]$CpuPercentage = 5
  )
  
  write-host "about to restrict user account $UserNameToRestrict to use ${CpuPercentage}% CPU"
  
    try
      {     
        $objUser = New-Object System.Security.Principal.NTAccount($UserNameToRestrict)
        $local:ResolvedSID= $objUser.Translate([System.Security.Principal.SecurityIdentifier]).Value.trim()   
      }
    catch
      {
        throw "Cannot resolve the User (or find its SID) for $UserNameToRestrict"
      }    
   $regpath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Quota System\${local:ResolvedSID}"
   #in creating a new key for this sid, it will remove any old item
  mkdir $regpath -Force -ErrorAction stop | out-null
  #as the old key if existing was removed by the above code, this will create a new value
   New-ItemProperty -Path $regpath  -Name "CpuRateLimit" -Value $CpuPercentage -PropertyType "DWord" -Force -ErrorAction stop | out-null   
  
  }
  </code></pre>
  
  <p>However while this does create the registry key per <a href="http://technet.microsoft.com/en-us/library/ff384148(v=ws.10).aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/ff384148(v=ws.10).aspx</a></p>
  
  <p>it has null effect on server 2012 or windows 8. Is this broken or is there a new way to do this in server 2012?</p>