Install Powershell and PowerCLI in Ubuntu 18.04 (Bionic Beaver) – Unsupported Workaround

EDIT: This was an unsupported work around and now 18.04 is officially supported, you can read my post about it here: Install Powershell and PowerCLI in Ubuntu 18.04 (Bionic Beaver)

Over the last few weeks, due to the increased compatibility and requirements for me to be using a Linux distro, I have decided to make a transition over to Linux (specifically Ubuntu) and one of the requirements for this process was the ability to install Powershell as I frequently use PowerCLI. However, It’s not as simple as an apt-get install cmdlet. I am by no means a developer or coder, but as you might know, I do create some scripts or tools now and again.

So, as part of this trial transition (who knows, might go back to windows – ghast!), I have managed to install Powershell and PowerCLI. This guide is for 18.04 but it uses 17.04 libraries as 18.04 is not official supported, yet. But it does work.

So, lets begin:

References:

Install Curl
root@epicworkstation:/home/raymond# apt install curl



Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcurl4
The following NEW packages will be installed
  curl libcurl4
0 to upgrade, 2 to newly install, 0 to remove and 1 not to upgrade.
Need to get 373 kB of archives.
After this operation, 1,036 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 libcurl4 amd64 7.58.0-2ubuntu3 [214 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 curl amd64 7.58.0-2ubuntu3 [159 kB]
Fetched 373 kB in 0s (3,986 kB/s)
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 174631 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.58.0-2ubuntu3_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.58.0-2ubuntu3_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up curl (7.58.0-2ubuntu3) ...

root@epicworkstation:/home/raymond#
Download libicu57 and install dependency:
root@epicworkstation:/home/raymond# wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu57_57.1-6ubuntu0.3_amd64.deb


--2018-05-03 09:21:17--  http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu57_57.1-6ubuntu0.3_amd64.deb
Resolving security.ubuntu.com (security.ubuntu.com)... 91.189.91.23, 91.189.88.162, 91.189.88.149, ...
Connecting to security.ubuntu.com (security.ubuntu.com)|91.189.91.23|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7691150 (7.3M) [application/x-debian-package]
Saving to: ‘libicu57_57.1-6ubuntu0.3_amd64.deb’

libicu57_57.1-6ubun 100%[===================>]   7.33M  5.42MB/s    in 1.4s    

2018-05-03 09:21:18 (5.42 MB/s) - ‘libicu57_57.1-6ubuntu0.3_amd64.deb’ saved [7691150/7691150]

root@epicworkstation:/home/raymond#
root@epicworkstation:/home/raymond# sudo apt install -f ./libicu57_57.1-6ubuntu0.3_amd64.deb



Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libicu57' instead of './libicu57_57.1-6ubuntu0.3_amd64.deb'
The following NEW packages will be installed
  libicu57
0 to upgrade, 1 to newly install, 0 to remove and 1 not to upgrade.
Need to get 0 B/7,691 kB of archives.
After this operation, 30.7 MB of additional disk space will be used.
Get:1 /home/raymond/libicu57_57.1-6ubuntu0.3_amd64.deb libicu57 amd64 57.1-6ubuntu0.3 [7,691 kB]
Selecting previously unselected package libicu57:amd64.
(Reading database ... 174638 files and directories currently installed.)
Preparing to unpack .../libicu57_57.1-6ubuntu0.3_amd64.deb ...
Unpacking libicu57:amd64 (57.1-6ubuntu0.3) ...
Setting up libicu57:amd64 (57.1-6ubuntu0.3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

root@epicworkstation:/home/raymond#

Downgrade libcurl
root@epicworkstation:/home/raymond# apt install libcurl3/bionic



Reading package lists... Done
Building dependency tree       
Reading state information... Done
Selected version '7.58.0-2ubuntu2' (Ubuntu:18.04/bionic [amd64]) for 'libcurl3'
The following packages will be REMOVED
  curl libcurl4
The following NEW packages will be installed
  libcurl3
0 to upgrade, 1 to newly install, 2 to remove and 1 not to upgrade.
Need to get 214 kB of archives.
After this operation, 392 kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 libcurl3 amd64 7.58.0-2ubuntu2 [214 kB]
Fetched 214 kB in 0s (3,901 kB/s)
(Reading database ... 174643 files and directories currently installed.)
Removing curl (7.58.0-2ubuntu3) ...
Removing libcurl4:amd64 (7.58.0-2ubuntu3) ...
Selecting previously unselected package libcurl3:amd64.
(Reading database ... 174631 files and directories currently installed.)
Preparing to unpack .../libcurl3_7.58.0-2ubuntu2_amd64.deb ...
Unpacking libcurl3:amd64 (7.58.0-2ubuntu2) ...
Setting up libcurl3:amd64 (7.58.0-2ubuntu2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...

root@epicworkstation:/home/raymond#

Import the public repository GPG keys
root@epicworkstation:/home/raymond# curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -



  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   983  100   983    0     0   5015      0 --:--:-- --:--:-- --:--:--  5015
OK
root@epicworkstation:/home/raymond# 
Register the Microsoft Ubuntu repository
root@epicworkstation:/home/raymond# sudo curl -o /etc/apt/sources.list.d/microsoft.list https://packages.microsoft.com/config/ubuntu/17.04/prod.list


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    78  100    78    0     0   1114      0 --:--:-- --:--:-- --:--:--  1114

root@epicworkstation:/home/raymond# 
Update the list of products
root@epicworkstation:/home/raymond# sudo apt-get update


Hit:1 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:4 http://packages.microsoft.com/repos/vscode stable InRelease [2,801 B]    
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease              
Ign:6 http://dl.google.com/linux/chrome/deb stable InRelease                   
Get:7 https://packages.microsoft.com/ubuntu/17.04/prod zesty InRelease [2,839 B]
Get:8 http://dl.google.com/linux/chrome/deb stable Release [1,189 B]           
Get:9 http://dl.google.com/linux/chrome/deb stable Release.gpg [819 B]
Hit:10 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Get:11 http://packages.microsoft.com/repos/vscode stable/main amd64 Packages [50.0 kB]
Get:12 https://packages.microsoft.com/ubuntu/17.04/prod zesty/main amd64 Packages [11.9 kB]
Get:13 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,338 B]
Fetched 70.9 kB in 1s (140 kB/s)                                 
Reading package lists... Done

root@epicworkstation:/home/raymond# 
root@epicworkstation:/home/raymond# sudo apt-get install -y powershell



Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  liblttng-ust-ctl4 liblttng-ust0 liburcu6
The following NEW packages will be installed
  liblttng-ust-ctl4 liblttng-ust0 liburcu6 powershell
0 to upgrade, 4 to newly install, 0 to remove and 1 not to upgrade.
Need to get 52.7 MB of archives.
After this operation, 142 MB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 liblttng-ust-ctl4 amd64 2.10.1-1 [80.8 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 liburcu6 amd64 0.10.1-1 [52.1 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 liblttng-ust0 amd64 2.10.1-1 [154 kB]
Get:4 https://packages.microsoft.com/ubuntu/17.04/prod zesty/main amd64 powershell amd64 6.1.0~preview.2-1.ubuntu.17.04 [52.4 MB]
Fetched 52.7 MB in 8s (6,816 kB/s)                                             
Selecting previously unselected package liblttng-ust-ctl4:amd64.
(Reading database ... 174659 files and directories currently installed.)
Preparing to unpack .../liblttng-ust-ctl4_2.10.1-1_amd64.deb ...
Unpacking liblttng-ust-ctl4:amd64 (2.10.1-1) ...
Selecting previously unselected package liburcu6:amd64.
Preparing to unpack .../liburcu6_0.10.1-1_amd64.deb ...
Unpacking liburcu6:amd64 (0.10.1-1) ...
Selecting previously unselected package liblttng-ust0:amd64.
Preparing to unpack .../liblttng-ust0_2.10.1-1_amd64.deb ...
Unpacking liblttng-ust0:amd64 (2.10.1-1) ...
Selecting previously unselected package powershell.
Preparing to unpack .../powershell_6.1.0~preview.2-1.ubuntu.17.04_amd64.deb ...
Unpacking powershell (6.1.0~preview.2-1.ubuntu.17.04) ...
Setting up liburcu6:amd64 (0.10.1-1) ...
Setting up liblttng-ust-ctl4:amd64 (2.10.1-1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up liblttng-ust0:amd64 (2.10.1-1) ...
Setting up powershell (6.1.0~preview.2-1.ubuntu.17.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

root@epicworkstation:/home/raymond# 
Start Powershell and Check Powershell Version
root@epicworkstation:/home/raymond# pwsh


PowerShell v6.1.0-preview.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/raymond> $PSVersionTable                                                                                                                                                                      


Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.2
OS                             Linux 4.17.0-041700rc2-generic #201804230622 SMP Mon Apr 23 10:25:30 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


Install PowerCLI and verify it installed
PS /home/raymond> Install-Module VMware.PowerCLI                                                                                                                                                       


Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the 
modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A



PS /home/raymond> Get-Module  -ListAvailable Vmware*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Directory: /usr/local/share/powershell/Modules                                                                                                                                                                 

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.7.0.8... VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-DeployRule...}
Script     6.7.0.8... VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile...}
Manifest   10.1.0.... VMware.PowerCLI                     
Script     6.7.0.8... VMware.Vim                          
Script     10.1.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script     10.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog...}
Script     10.1.0.... VMware.VimAutomation.Common         
Script     10.1.0.... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer...}
Script     6.5.4.7... VMware.VimAutomation.HA             Get-DrmInfo
Script     7.1.0.7... VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}
Script     10.0.0.... VMware.VimAutomation.License        Get-LicenseDataManager
Script     10.1.0.... VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtService}
Script     10.0.0.... VMware.VimAutomation.PCloud         {Connect-PIServer, Disconnect-PIServer, Get-PIComputeInstance, Get-PIDatacenter}
Script     10.1.0.... VMware.VimAutomation.Sdk            
Script     10.0.0.... VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}
Script     10.1.0.... VMware.VimAutomation.Storage        {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePolicy, Get-KeyManagementServer...}
Script     1.2.0.0    VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script     10.1.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch...}
Script     10.0.0.... VMware.VimAutomation.Vmc            {Connect-Vmc, Disconnect-Vmc, Get-VmcService, Connect-VmcServer...}
Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition...}
Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance...}

Process is now complete.

One Comment

    Jon Berg

    Very nice, thanks!

Leave a Reply

Your email address will not be published.

*
*