Automation Blog

from Stefan Schnell

When an action (script) is created in VCF Automation 8, it is possible to select different execution environments. Each of these execution environments runs in a container. One of these execution environments is PowerCLI.

Information About the PowerCLI Infrastructure


VMware PowerCLI is a set of PowerShell cmdlets to manage and automate the VMware infrastructure. This approach also offers the possibility to use the dotNET, which is underlying of PowerShell. To know which dotNET version comes to use can be very important, e.g. to know which classes are available. Here an approach how to detect this information.

function Handler([Object]$context, [Object]$inputs) {

  Write-Host "`n>>>Get-Host<<<"
  $getHost = Get-Host
  Write-Host "Name: $($getHost.Name)"
  Write-Host "PSVersion: $($getHost.Version)"
  Write-Host "CurrentCulture: $($getHost.CurrentCulture)"
  Write-Host "CurrentUICulture: $($getHost.CurrentUICulture)"

  Write-Host "`n>>>PSVersionTable<<<"
  foreach ($PSInformation in $PSVersionTable.GetEnumerator()) {
    Write-Host "$($PSInformation.Name) : $($PSInformation.Value)"
  }

  Write-Host "`n>>>System.Environment.Version<<<"
  $version = [System.Environment]::Version
  Write-Host "Common Language Runtime Version: $($version)"

  If ($PSVersionTable.Platform -eq "Unix") {
    Write-Host "`n>>>OS Release<<<"
    $processInfo = New-Object System.Diagnostics.ProcessStartInfo
    $processInfo.FileName = "cat"
    $processInfo.RedirectStandardError = $true
    $processInfo.RedirectStandardOutput = $true
    $processInfo.UseShellExecute = $false
    $processInfo.Arguments = "/etc/os-release"
    $process = New-Object System.Diagnostics.Process
    $process.StartInfo = $processInfo
    $process.Start() | Out-Null
    $process.WaitForExit()
    [String]$stdout = $process.StandardOutput.ReadToEnd()
    Write-Host $stdout
  }

}

[Object]$context = @{}
[Object]$inputs = @{}
Handler($context, $inputs)

Get-Host

The Get-Host cmdlet represents the hosting PowerShell program. It provides information about the PowerShell version and that there is no setting for the culture in the default, which has an effect on the date format, for example.

get information with the powershell cmdlet get-host

PSVersionTable

The automatic variable $PSVersionTable delivers information about the PowerShell version and edition and we see here that we are working with a Photon operating system.

get information with the variable psversiontable

System.Environment.Version

The System.Environment.Version property of the dotNET delivers information about the using common language runtime (CLR). From this interesting further information can already be derived.

get information with dotnet method system.environment.version

OS Release

This file contain operating system identification data.

Conclusion

If you plan to add a dotNET type, in the context of PowerCLI or PowerShell, it is very important to know which environment is used. The CLR and language support define our capabilities, so knowing that is very important.

Addendum

With the release 8.12 of Aria Automation offers the Orchestrator new runtime environments. One of these are PowerShell, without PowerCLI.

VCF Automation
Release
PowerShell
Release
PS
Version
CLR
Version
OS
Version
9.1.0PowerCLI 9.0.0 (PowerShell 7.4)7.4.118.0.17Photon 5.0
9.1.0PowerShell 7.47.4.118.0.17Photon 5.0
9.0.0PowerCLI 13 (PowerShell 7.4)7.4.38.0.7Photon 5.0
9.0.0PowerShell 7.47.4.38.0.7Photon 5.0
8.18.1PowerCLI 13 (PowerShell 7.4)7.4.38.0.7Photon 5.0
8.18.1PowerShell 7.47.4.38.0.7Photon 5.0
8.18.0PowerCLI 12 (PowerShell 7.4)7.4.18.0.1Photon 4.0
8.18.0PowerCLI 13 (PowerShell 7.4)7.4.18.0.1Photon 4.0
8.18.0PowerShell 7.47.4.18.0.1Photon 4.0
8.17.0PowerCLI 12 (PowerShell 7.4)7.4.18.0.1Photon 4.0
8.17.0PowerCLI 13 (PowerShell 7.4)7.4.18.0.1Photon 4.0
8.17.0PowerShell 7.47.4.18.0.1Photon 4.0
8.16.2PowerCLI 12 (PowerShell 7.4)7.4.18.0.1Photon 4.0
8.16.2PowerCLI 13 (PowerShell 7.4)7.4.18.0.1Photon 4.0
8.16.2PowerShell 7.47.4.18.0.1Photon 4.0
8.16.1PowerCLI 12 (PowerShell 7.2)7.2.166.0.24
8.16.1PowerShell 7.37.3.97.0.13
8.16.0PowerCLI 12 (PowerShell 7.2)7.2.166.0.24
8.16.0PowerShell 7.37.3.97.0.13
8.14.1PowerCLI 12 (PowerShell 7.2)7.2.166.0.24
8.14.1PowerShell 7.37.3.97.0.13
8.14.0PowerCLI 12 (PowerShell 7.2)7.2.126.0.19
8.14.0PowerShell 7.37.3.67.0.9
8.13.1PowerCLI 12 (PowerShell 7.2)7.2.126.0.19
8.13.1PowerShell 7.37.3.67.0.9
8.12.0PowerCLI 12 (PowerShell 7.1)7.1.75.0.16
8.12.0PowerShell 7.37.3.37.0.3
8.11.0PowerCLI 12 (PowerShell 7.1)7.1.75.0.16
8.10.2PowerCLI 12 (PowerShell 7.1)7.1.55.0.11
8.9.0PowerCLI 12 (PowerShell 7.1)7.1.55.0.11
8.5.1PowerCLI 12 (PowerShell 7.0)7.0.03.1.3

References