Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Converting from PowerCLI to JavaScript

$
0
0

I'm attempting to convert a PowerCLI report to JavaScript.  I'm looking to convert a lot of PowerCLI-specific things to JavaScript so I can do the same things in Orchestrator without having to call PowerCLI scripts.

Using Project Onyx is great, but I need to be able to convert things like loops, arrays, try-catch, for-each, etc.,  that Onyx can't convert automatically.   Calling PowerCLI scripts from Orchestrator, getting the results back and processing them is going to get cumbersome and drive me to begin writing in straight JavaScript when I don't want to do it natively in Orchestrator.

 

How would I convert a report like this to JavaScript for use in orchestrator? It imports a list of VMs in .csv format, checks if they are in vCenter, then exports the list of VMs that are in vCenter back out to .csv.

 

$array = @()

Import-Csv c:\listofvms.csv -UseCulture |

%{

  Try {

      Get-VM -Name $_.VMName -ErrorAction Stop | Out-Null 

      } 

      Catch {    return 

      } 

      $array += $_ 

      }

      $array | Export-Csv c:\nov-decStillExisting.csv -NoTypeInformation -UseCulture

 

 

Perhaps I need to get familiar with all the JavaScript functions, syntax, try-catch, loops, array definitions, etc, and then I can use Onyx to covert the actual cmdlets?  Has anyone gone through a PowerCLI to JavaScript transition and has pointers?


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>