I only put the backslash in to try and escape the dash character in the name. Now I get:
$nameToExclude = 'TWB TST E5\-2680 App Delivery'
$nameToExclude = [System.Text.RegularExpressions.Regex]::Escape($nameToExclude)
Get-View -ViewType ClusterComputeResource -Filter @{'Name'="[^$($nameToExclude)]"} | Select Name
Get-View : 5/17/2018 11:27:42 AM Get-View parsing "[^TWB\ TST\ E5\\-2680\ App\ Delivery]" - [x-y]
range in reverse
order.
At line:1 char:1
+ Get-View -ViewType ClusterComputeResource -Filter @{'Name'="[^$($name ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
Or if I take the backslash out, back to where we were before:
$nameToExclude = 'TWB TST E5-2680 App Delivery'
$nameToExclude = [System.Text.RegularExpressions.Regex]::Escape($nameToExclude)
Get-View -ViewType ClusterComputeResource -Filter @{'Name'="[^$($nameToExclude)]"} | Select Name
Get-View : 5/17/2018 11:28:01 AM Get-View parsing "[^TWB\ TST\ E5-2680\ App\ Delivery]" - [x-y] ra
nge in reverse
order.
At line:1 char:1
+ Get-View -ViewType ClusterComputeResource -Filter @{'Name'="[^$($name ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView