VMware Horizon Community
Perttu
Enthusiast
Enthusiast

Uagdeploy.ps1, PowerShell 7 and Linux

If you get again bored while fixing official uagdeploy scripts to work with PowerShell on Linux, please patch these.

These are diff outputs and can be applied to originals with patch command.

uagdeploy.ps1:

121c121,125

< $ovftool = "C:\Program Files\VMware\VMware OVF Tool\ovftool.exe"

---

> if ($IsLinux -or $IsMacOS) {

> $ovftool = (Get-Command ovftool).Path

> }

> else {

> $ovftool = "C:\Program Files\VMware\VMware OVF Tool\ovftool.exe"

123,125c127,130

< if (!(Test-path $ovftool)) {

< WriteErrorString "Error: ovftool command not found ($ovftool)"

< Exit

---

> if (!(Test-Path $ovftool)) {

> WriteErrorString "Error: ovftool command not found ($ovftool)"

> Exit

> }

172c177,181

< $configfile = "${env:APPDATA}\VMware\ovftool.cfg"

---

> if ($isLinux -or $isMac) {

> $configfile = "$HOME/ovftool.cfg"

> } else {

> $configfile = "${env:APPDATA}\VMware\ovftool.cfg"

> }

uagdeploy.psm1:

95a96,100

>     if ( $PSVersionTable.PSVersion.Major -ge 7) {

>         # Using umanaged memory does not work anymore with PowerShell 7+ Core on Windows/Linux

>         ConvertFrom-SecureString -SecureString $SecurePassword -AsPlainText

>     } else {

>

107c112,113

<    

---

>

>     }

597,598d602

<     $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2

<

600c604

<         $response = $cert.Import($sslCertsFilePfx, '','DefaultKeySet')

---

>         $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -Args $sslCertsFilePfx, '', 'DefaultKeySet'

602c606,607

<         if ($_.Exception.InnerException.HResult -eq 0x80070056) { # ERROR_INVALID_PASSWORD

---

>         #  0x23076071 is "error:23076071:PKCS12 routines:PKCS12_parse:mac verify failure" on a Linux

>         if ($_.Exception.InnerException.HResult -eq 0x80070056 -or $_.Exception.InnerException.HResult -eq 0x23076071 ) { # ERROR_INVALID_PASSWORD

644d648

<     $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2

647,650c651,654

<         $response = $cert.Import($sslCertsFilePfx, $pwd,'DefaultKeySet')

<     } catch {

<         WriteErrorString "Error: The specified PFX certificate file is invalid ($sslCertsFilePfx)"

<         return $false

---

>         $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -Args $sslCertsFilePfx, $pwd, 'DefaultKeySet'

>     } catch {      

> WriteErrorString "Error: The specified PFX certificate file is invalid ($sslCertsFilePfx)"

> return $false

730c734

<      $Content = Get-Content -Path $sslCertsFilePfx -Encoding Byte

---

>      $Content = [System.IO.File]::ReadAllBytes($sslCertsFilePfx)

1642c1646

< $Content = Get-Content -Path $securidServerConfigFile -Encoding Byte

---

> $Content = [System.IO.File]::ReadAllBytes($securidServerConfigFile)

3674,3675c3678,3685

<

< $vmwareDir = "${env:APPDATA}\VMware"

---

>     if ($IsLinux -or $IsMac) {

>         #$vmwareDir = $env:HOME + "/VMware"

>         #Above not needed afterall

>         return

>     }

> else {

>         $vmwareDir = "${env:APPDATA}\VMware"

>     }

0 Kudos
0 Replies