vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 90 forks source link

How to filter output based on parameter and value #535

Closed Crypto-Gi closed 6 years ago

Crypto-Gi commented 6 years ago

I am learning powernsx cmdlts, i need to know how to could i possibles filter results based on any parameter. For example:

PS C:> Get-NsxIpSet

Above cmd will show all ipset , but if i need to filter "isUniversal=true" only ipsets , then how could I possible do that.

alagoutte commented 6 years ago

You can use Get-NsxIpSet -UniversalOnly

for get what it is possible with cmdlet, you can use help Get-NsxIPSet -example (or -full)

nmbradford commented 6 years ago

More generically (standard PowerShell approach) :

Get-NsxIpSet | Where { $_.isUniversal -eq 'true' }

You can use this approach with any property on any object. Do some basic research on PowerShell objects and how to use the PowerShell pipeline effectively and this will become second nature.