VMware Cloud Community
IgorAfonin
Contributor
Contributor
Jump to solution

Conditional function onto "where clause"

Hi guys,

How can i get a condition with function onto "where" ?

somthing like that:

Get-VM | where{@{N="Path";E={Get-Path -Object $_}} -Like "*SAP*"}

I do not want get a container with select-objects properties, i want take an a object.

It's working when i call function in Select-objects level and then check the result column into "where".

PS. sorry for my english i am not native speaker.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-VM | where{(Get-Path -Object $_) -Like "*SAP*"}

But it depends on what the function Get-Path is actually returning ?

Does it return a [string] object ? If yes, the above should work.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-VM | where{(Get-Path -Object $_) -Like "*SAP*"}

But it depends on what the function Get-Path is actually returning ?

Does it return a [string] object ? If yes, the above should work.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
IgorAfonin
Contributor
Contributor
Jump to solution

Luc, thank for your comment, working perfectly.

0 Kudos