Exchange 2010 Powershell指令碼攻略(九)
ConfigureNetworkProtocolParameters
$local:CommandAppCmd = "$env:windirSystem32inetsrvappcmd.exe"
function local:Invoke-ExpressionWithConfiguredLogging([string]$expression)
{
if ((Get-Command Invoke-ExpressionWithLoggin[g] -CommandType Function) -ne $null)
{
# Executing as a part of workflow
Invoke-ExpressionWithLogging $expression
}
else
{
# Default PowerShell way
Invoke-Expression $expression
}
}
function local:Run-CommandWithConfiguredLogging([string]$exeName, [string]$parameters)
{
if ((Get-Command Start-SetupProces[s] -CommandType CmdLet) -ne $null)
{
# Executing as a part of setup
Start-SetupProcess -Name $exeName -Args $parameters
}
else
{
Invoke-ExpressionWithConfiguredLogging "$exeName $parameters"
}
}
function local:SetRegistryValueNoLogging([string]$key, [string]$valueName, [object]$value, [ScriptBlock]$keyDoesNotExist)
{
if (-not (Test-Path $key))
{
& $keyDoesNotExist
}
if ($value -ne $null)
{
Set-ItemProperty -path $key -name $valueName -value $value
}
else
{
Remove-ItemProperty -path $key -name $valueName
}
}
function script:Set-RegistryValue([string]$key, [string]$valueName, [object]$value, [ScriptBlock]$keyDoesNotExist = {[void](New-Item -path $key)})
{
$initialErrorCount = $error.Count
# $value can be of a variety of types and even $null
SetRegistryValueNoLogging $key $valueName $value $keyDoesNotExist
if ($error.Count -ne $initialErrorCount `
-and (Get-Command Write-ExchangeSetupLo[g] -CommandType CmdLet) -ne $null)
{
# Executing as a part of setup
$error[0..($error.Count - $initialErrorCount - 1)] `
| Write-ExchangeSetupLog $_ $_.Exception
# Reset the errors if the only thing that failed was a registry operation
if ($initialErrorCount -eq 0)
{
$error.Clear()
}
}
}
#########################################################################################################################
# Actual logic
#########################################################################################################################
# Configures a Global Catalog running on the current machine to listen
# on the standard NSPI Rpc-over-Http port 6004. This would enable Rpc-over-Http
# connections from Outlook clients to a GC, RpcProxy'ed by CAS boxes.
#
# For more information, see
# - (EXCHG.65).aspx
function Enable-NspiOverRpcOverHttpForGlobalCatalog
{
Set-RegistryValue `
'HKLM:SystemCurrentControlSetServicesNTDSParameters' `
'NSPI interface protocol sequences' `
([string[]]'ncacn_http:6004') `
{throw "This setting can only be enabled on Windows Domain Controllers"}
}
function Enable-RpcOverTcpPortScaling
{
Set-RegistryValue `
'HKLM:SOFTWAREPoliciesMicrosoftWindows NTRpc' `
'EnableTcpPortScaling' `
([int]1)
}
function Enable-ExtendedTcpPortRange([string[]]$protocols = ('ipv4', 'ipv6'))
{
# See for details on this setting.
# Start from port 6005, as Exchange and SQL have assigned ports below.
$protocols | foreach {Run-CommandWithConfiguredLogging netsh "interface $_ set dynamicportrange protocol=tcp startport=6005 numberofports=59530"}
}
function Set-IisKernelModeAuthentication([bool]$isEnabled)
{
$mode = @{$true='true'; $false='false'}[$isEnabled]
Run-CommandWithConfiguredLogging $CommandAppCmd "set config /section:windowsAuthentication /useKernelMode:$mode"
}
function Set-IisApplicationPoolRecycling([string]$appPool, [TimeSpan]$idleTimeout, [TimeSpan]$periodicRestart)
{
Run-CommandWithConfiguredLogging $CommandAppCmd "set config /section:applicationPools `"/[name='$appPool'].processModel.idleTimeout:$idleTimeout`""
Run-CommandWithConfiguredLogging $CommandAppCmd "set config /section:applicationPools `"/[name='$appPool'].recycling.periodicRestart.time:$periodicRestart`""
}
function Set-AutoConfigureRpcProxyForGlobalCatalogs([bool]$isEnabled = $true)
{
Set-RegistryValue `
'HKLM:SYSTEMCurrentControlSetServicesMSExchangeServiceHostRpcHttpConfigurator' `
'ConfigureGCPorts' `
(@{$true=[int]1; $false=$null}[$isEnabled])
}
function Set-NtlmLoopbackCheck([bool]$isEnabled = $true)
{
# See for details on this setting.
# Disables NTLM loopback check that prevents NTLM authentication from
# succeeding against a local server if an FQDN was used to address it.
Set-RegistryValue `
'HKLM:SYSTEMCurrentControlSetControlLsa' `
'DisableLoopbackCheck' `
(@{$true=$null; $false=[int]1}[$isEnabled])
}
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23700676/viewspace-1052335/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Exchange 2010 Powershell指令碼攻略(十五)指令碼
- Exchange 2010 Powershell指令碼攻略(十四)指令碼
- Exchange 2010 Powershell指令碼攻略(十三)指令碼
- Exchange 2010 Powershell指令碼攻略(十二)指令碼
- Exchange 2010 Powershell指令碼攻略(十一)指令碼
- Exchange 2010 Powershell指令碼攻略(十)指令碼
- Exchange 2010 Powershell指令碼攻略(八)指令碼
- Exchange 2010 Powershell指令碼攻略(七)指令碼
- Exchange 2010 Powershell指令碼攻略(六)指令碼
- Exchange 2010 Powershell指令碼攻略(五)指令碼
- Exchange 2010 Powershell指令碼攻略(四)指令碼
- Exchange 2010 Powershell指令碼攻略(三)指令碼
- Exchange 2010 Powershell指令碼攻略(二)指令碼
- Exchange 2010 Powershell指令碼攻略(一)指令碼
- powershell指令碼指令碼
- PowerShell 指令碼中的密碼指令碼密碼
- PowerShell 指令碼執行策略指令碼
- powershell重新命名指令碼指令碼
- Exchange 2010搭建
- Bash指令碼debug攻略指令碼
- 開機自啟動Powershell指令碼指令碼
- linux shell 指令碼攻略筆記Linux指令碼筆記
- 【黑客基礎】Windows PowerShell 指令碼學習(上)黑客Windows指令碼
- 最簡單的一個powershell的指令碼指令碼
- Statspack之九-其它重要指令碼指令碼
- Exchange 2010需要的網路埠
- 微軟宣佈全新命令列+指令碼工具:PowerShell 7微軟命令列指令碼
- 五個實用的SQL Server PowerShell指令碼OMSQLServer指令碼
- 利用powershell指令碼Windows hosts記錄替換IP指令碼Windows
- Win10使用Powershell提示禁止執行指令碼怎麼辦 Win10使用Powershell提示禁止執行指令碼如何解決Win10指令碼
- shell指令碼攻略--DNS正向解析一鍵部署指令碼DNS
- 利用 Powershell 編寫簡單的瀏覽器指令碼瀏覽器指令碼
- 【連結】LINUX SHELL指令碼攻略筆記[速查]Linux指令碼筆記
- 《Linux Shell指令碼攻略(第2版)》書評Linux指令碼
- nuget打包檔案丟失如何使用powershell指令碼解決指令碼
- 使用VSCode遠端除錯惡意Powershell指令碼VSCode除錯指令碼
- 【VMware VCF】使用 PowerShell 指令碼管理 SDDC Manager 中的軟體包。指令碼
- 九陰真經新手必看1-30級入門攻略 九陰真經新手攻略