In many cases VMware vSphere controlled over Raspberry Pi can be a userful solution. Some possible usages are shown in the following tutorials.
Important!
PowerShell Core and PowerCLI
Installation
$ apt-get install libunwind8
$ cd /tmp
Note: The following placeholders <x>
stand for the latest release number of the current development which can be checked here.
$ wget https://github.com/PowerShell/PowerShell/releases/download/v<x>.<x>.<x>/powershell-<x>.<x>.<x>-linux-arm32.tar.gz
$ mkdir /<myPath>/powerShellCore
$ tar -xvf ./powershell-<x>.<x>.<x>-linux-arm32.tar.gz -C /<myPath>/powerShellCore
Start PowerShell Core …
$ /<myPath>/powerShellCore/pwsh
…and check currently installed PowerShell Core version:
$PSVersionTable.PSVersion
Now install PowerCLI:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser
Check currently installed PowerCLI version:
Get-PowerCLIVersion
Optional: Disable warning messages:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
Optional: Disable certificate checks:
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
Quit PowerShell Core:
exit
Optional: Make PowerShell Core available globally:
$ /<myPath>/pwsh -c New-Item -ItemType SymbolicLink -Path "/usr/bin/pwsh" -Target "\$PSHOME/pwsh" -Force
Update PowerShell Core to the latest release version
$ apt-get upgrade powershell
Connect to a vSphere host
Connect-VIserver -Server <myTargetHostIPaddress> -User <myUser> -Password <myUserPassword>
Save current ESXi configuration into a file
Get-VMHostFirmware -VMHost <myTargetIPaddress> -BackupConfiguration -DestinationPath /<myPath>/
Automation via scripts
$ mkdir /<myPath>/<myScriptFolder>
Then:
$ touch /<myPath>/<myScriptFolder>/<myBashScriptFile>.sh
$ touch /<myPath>/<myScriptFolder>/<myPowerCLIscriptFile>.ps
$ vi /<myPath>/<myScriptFolder>/<myBashScriptFile>.sh
Add the following content:
/<myPowerShellCorePath>/pwsh /<myPath>/<myScriptFolder>/<myPowerCLIscriptFile>.ps
Save the file and quit the editor.
$ vi /<myPath>/<myScriptFolder>/<myPowerCLIscriptFile>.sh
Add the following content (In the following script choose VM names exactly the same way the VMs are named on ESXi host) (Note: The start-sleep
command can be used optionally for delayed power-on, for example when there is a domain controller which generally always should get available at first inside a network environment):
Connect-VIServer -Server <myTargetHostIPaddress> -User <myUser> -Password <myUserPassword> Start-VM <myFirstVM> start-sleep -s 30 Start-VM <mySecondVM> Start-VM <myThirdVM> Start-VM <myFourthVM> Exit
Save the file and quit the editor.
$ chmod +x /<myPath>/<myScriptFolder>/<myBashScriptFile>.sh
$ chmod +x /<myPath>/<myScriptFolder>/<myPowerCLIscriptFile>.ps
Beware: Due to certificate verification and therefore for successful scripting it is required to connect manually once when connecting for the very first time between client und server via remote SSH. (Alternatively: Do a certificate import.)!
Update to latest PowerCLI version
$ /<myPath>/powerShellCore/pwsh
…then update PowerCLI:
Update-Module VMware.PowerCLI
Quit PowerShell Core:
exit
Clear PowerShell Core history
Remove-Item (Get-PSReadlineOption).HistorySavePath
For PowerShell cache clearing it is necessary to quit PowerShell Core now:
exit
Appreciate my work?
Buy me a coffee or PayPal
Source(s):
Installing VMware PowerCLI 10 on a Raspberry Pi
VMware PowerCLI Blog
Installing PowerShell Core on Linux
Additional PowerCLI commands for vSphere control:
PowerCLI Cmdlets