First try script will read exception RL name not equal "FTP_XML"
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "FTP_XML" }
$ReceiveLocations
Second try script will not read exception RLS name not equal "FTP_XML", "RL2" and give all Disabled RLS
[ARRAY]$ReceiveLocations = Get-WmiObject MSBTS_ReceiveLocation -Namespace 'root\MicrosoftBizTalkServer' -Filter '(IsDisabled = True)' |
Where-Object { $_.Name -ne "FTP_XML", "RL2" }
$ReceiveLocations
How can I include exception list more then what we have as exception?
OR
We can read the variable as below from text file, but it also not reading from TEXT file (all list of RLs start with new line) and gives me all disabled RLs.
[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
Using
-ne
will check if a single value is not the same as a list of values, which obviously will always evaluate to true. The operator for checking if a given value does not exist in a list of values is-notcontains
($list -notcontains $value
). On PowerShell v3 and newer you can also use the operator-notin
($value -notin $list
), which probably feels more natural to most users.To read a list of values from a file use
Get-Content
, as Abhijith pk already mentioned in the comments to your question.Note that you must not put the list variable in quotes.