Function set-maxthreadpolicy {
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact="Medium")]
Param([string]$policy,
[int]$count )
$rootDSE = [ADSI]"LDAP://rootDSE"
$config = $rootDSE.configurationNamingContext
$queryPolicies = [adsi]"LDAP://CN=Default Query Policy,CN=Query-Policies,cn=Directory Service,cn=Windows NT,CN=Services,$config"
$oldvalue = $queryPolicies.lDAPAdminLimits | ?{$_ -match $policy}
$queryPolicies.PutEx(3,"lDAPAdminLimits",@("$policy=$count"))
$queryPolicies.Setinfo()
$queryPolicies.PutEx(4,"lDAPAdminLimits",@("$oldvalue"))
$queryPolicies.Setinfo()
}
Function put-maxthread {
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact="Medium")]
param (
[parameter(Mandatory=$true,ValueFromPipeline=$false,Position=1,ParameterSetName="ByFarm",HelpMessage="Enter the farmID")]
[Microsoft.exchange] $Farm,
[parameter(Mandatory=$true,ValueFromPipeline=$false,Position=2,ParameterSetName="ByNetwork",HelpMessage="Enter the networkID")]
[Microsoft.exchange] $Network,
[parameter(Mandatory=$true,ValueFromPipeline=$false,Position=3,ParameterSetName="All",HelpMessage="ALL exch servers")]
[switch] $All
)
$vms = $null
switch ($PsCmdlet.ParameterSetName)
{
"ByFarm" { $vms = Get-GridVM -Role exch01 -Farm $Farm }
"ByNetwork" { $vms = Get-GridVM -Role exch01 -Network $Network }
"All" { $vms = Get-GridVM -Role exch01}
}
$password = Read-Host -assecurestring "Please enter your password for SPODS Administrator account"
Import-Module activedirectory
foreach($vm in $vms)
{
Write-Verbose $vm
$endfqdn = (get-griddsfarm -identity $vm.farmid).dsfqdn
$fqdn = $vm.name + "." + $endfqdn
$user = "$endfqdn\Administrator"
$creds = New-Object System.Management.Automation.PSCredential ($user, $password)
$Domain = get-addomain -server $fqdn
$PDCEmulator = ($Domain).PDCEmulator
if ($fqdn -eq $PDCEmulator) {
Write-Host "$fqdn is the PDC Emulator"-ForegroundColor Green
Write-Host "Connecting to $fqdn as $user" -ForegroundColor Gray
Invoke-Command -Credential $creds -ComputerName $fqdn -ScriptBlock {
Import-Module activedirectory
$SPODSDomain = get-addomain
$Target = ($SPODSDomain).DomainControllersContainer
$Forest = ($SPODSDomain).Forest
policy= invoke-command -scriptblock { set-maxthreadpolicy -policy MaxPoolThreads -count 5}
Write-Host "$policy is not 4 " -ForegroundColor Green
}
} }
} # THE END
I receive this error
The term 'set-maxthreadpolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (set-maxthreadpolicy:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException