Thursday, October 31, 2013

SharePoint Request Management



$w = Get-SPWebApplication -identity http://sp2013wfe1

$rmset = $w | Get-SPRequestManagementSettings

New-SPSite -Url http://sp2013wfe1 -owneralias sp2013\Administrator -ownerEmail administrator@sp2013.loc

New-SPSite -url http://www.contoso.loc -HostHeaderWebApplication $w -owneralias sp2013\Administrator -owneremail administrator@sp2013.loc -template sts#0

New-SPSite -url http://www.fabrikam.loc -HostHeaderWebApplication $w -owneralias sp2013\Administrator -owneremail administrator@sp2013.loc -template sts#0

$mp1 = Add-SPRoutingMachinePool -RequestManagementSettings $rmset -Name MachinePool1 -MachineTargets @("SP2013WFE1")

Get-SPRoutingMachinePool -RequestManagementSettings $rmset

$rmset | Get-SPRoutingMachineInfo -Name "sp2013wfe1"

$rmmi = $rmset | Get-SPRoutingMachineInfo -Name "sp2013wfe1"
Set-SPRoutingMachineInfo -Identity $rmmi -StaticWeight 9

$criteria = New-SPRequestManagementRuleCriteria -Property UserAgent -MatchType Regex -Value ".*Microsoft Office OneNote 2013*"
$rmset | Add-SPThrottlingRule -Name "Refuse OneNote Requests" -Criteria $criteria -Threshold 8

$criteria = New-SPRequestManagementRuleCriteria -Property Url -MatchType Regex -Value ".*\.pdf"
$rule = Add-SPRoutingRule -RequestManagementSettings $rmset -Name SendAllPdf2mp1 -ExecutionGroup 0 -MachinePool $mp1 -Criteria $criteria

$criteria = New-SPRequestManagementRuleCriteria -Property Host -MatchType Equals -Value "www.fabrikam.loc"
$rule = Add-SPRoutingRule -RequestManagementSettings $rmset -Name fabrikam2mp1 -ExecutionGroup 1 -MachinePool $mp1 -Criteria $criteria

%systemroot%\System32\runas.exe /user:user@dc07.loc "%ProgramFiles(x86)%\Internet Explorer\iexplore.exe