使用 PowerShell 监视具有自动修复功能的 BizTalk Server 端口
Monitoring BizTalk Server Ports with Auto-Healing capabilities with PowerShell
第一次尝试脚本将读取异常 RL 名称不等于 "FTP_XML"
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "FTP_XML" }
$ReceiveLocations
第二次尝试脚本不会读取异常 RLS 名称不等于 "FTP_XML"、"RL2" 并给出所有禁用的 RLS
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "FTP_XML", "RL2" }
$ReceiveLocations
我怎样才能包含比我们作为例外更多的例外列表?
或
我们可以从文本文件中读取如下变量,但它也不能从文本文件中读取(所有 RL 列表都以换行符开头)并给出所有禁用的 RL。
[ARRAY]$exceptionList = Get-ChildItem C:\Users\Dipen\Desktop \Exception_List.txt
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "$exceptionList" }
$ReceiveLocations
使用 -ne
将检查单个值是否与值列表不同,这显然将始终评估为真。用于检查给定值是否不存在于值列表中的运算符是 -notcontains
($list -notcontains $value
)。在 PowerShell v3 和更新版本上,您还可以使用运算符 -notin
($value -notin $list
),这对大多数用户来说可能更自然。
$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { 'FTP_XML', 'RL2' -notcontains $_.Name }
要从文件中读取值列表,请使用 Get-Content
,因为 已在您的问题的评论中提到。
$exceptionList = Get-Content C:\Users\Dipen\Desktop \Exception_List.txt
$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $exceptionList -notcontains $_.Name }
请注意,您不能将列表变量放在引号中。
第一次尝试脚本将读取异常 RL 名称不等于 "FTP_XML"
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "FTP_XML" }
$ReceiveLocations
第二次尝试脚本不会读取异常 RLS 名称不等于 "FTP_XML"、"RL2" 并给出所有禁用的 RLS
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "FTP_XML", "RL2" }
$ReceiveLocations
我怎样才能包含比我们作为例外更多的例外列表?
或
我们可以从文本文件中读取如下变量,但它也不能从文本文件中读取(所有 RL 列表都以换行符开头)并给出所有禁用的 RL。
[ARRAY]$exceptionList = Get-ChildItem C:\Users\Dipen\Desktop \Exception_List.txt
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "$exceptionList" }
$ReceiveLocations
使用 -ne
将检查单个值是否与值列表不同,这显然将始终评估为真。用于检查给定值是否不存在于值列表中的运算符是 -notcontains
($list -notcontains $value
)。在 PowerShell v3 和更新版本上,您还可以使用运算符 -notin
($value -notin $list
),这对大多数用户来说可能更自然。
$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { 'FTP_XML', 'RL2' -notcontains $_.Name }
要从文件中读取值列表,请使用 Get-Content
,因为
$exceptionList = Get-Content C:\Users\Dipen\Desktop \Exception_List.txt
$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $exceptionList -notcontains $_.Name }
请注意,您不能将列表变量放在引号中。