VMware Cloud Community
BBB36
Enthusiast
Enthusiast
Jump to solution

Powershell code conversion to Javascript

Hi. Anyone know if there's a software or website to convert Powershell code to Javascript?

Or how to specifically convert this where statement example - "where { $_.Model -match "Some_Name" }"  from Powershell to a compatibe Javscript code?

Would appreciate any help.

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

The PowerShell code checks whether Model property of the object matches some regular expression ("Some_Name" string in this case).

In Javascript, there is similar regular expressions matching functionality via RegExp#test() method. Examples of its usage can be found online, check eg.  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test

View solution in original post

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

The PowerShell code checks whether Model property of the object matches some regular expression ("Some_Name" string in this case).

In Javascript, there is similar regular expressions matching functionality via RegExp#test() method. Examples of its usage can be found online, check eg.  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test

Reply
0 Kudos
BBB36
Enthusiast
Enthusiast
Jump to solution

Thanks llian. I'll take a look.

Reply
0 Kudos