{"id":1140,"date":"2018-03-04T00:57:43","date_gmt":"2018-03-04T05:57:43","guid":{"rendered":"https:\/\/ithinkvirtual.com\/?p=1140"},"modified":"2018-03-31T07:26:19","modified_gmt":"2018-03-31T11:26:19","slug":"install-powershell-and-vmware-powercli-on-macos","status":"publish","type":"post","link":"https:\/\/ithinkvirtual.com\/2018\/03\/04\/install-powershell-and-vmware-powercli-on-macos\/","title":{"rendered":"Install PowerShell and VMware PowerCLI on macOS"},"content":{"rendered":"
Just a few days ago, PowerShell Core v6.0<\/a> was released for Windows, Linux, and macOS systems. \u00a0Alongside this release came the release of VMware PowerCLI 10.0.0.78953<\/a> which is VMware’s own “PowerShell-like” utility. \u00a0In this post, I am going to show how to install both on to a macOS system. \u00a0Let’s get to it!<\/p>\r\n There are a few prerequisites needed before PowerShell can be installed on macOS which I will cover, and they are as follows:<\/p>\r\n Per the instructions on the Homebrew site, copy and paste the following command into a terminal window to install Homebrew.<\/p>\r\n <\/a><\/p>\r\n This will prompt you to press Enter<\/strong><\/em> to continue and the prompt you to enter your password. \u00a0It will also check if Xcode command line tools are installed, and if not, it will download and install it for you before completing the installation of Homebrew. Nice!<\/p>\r\n <\/a> <\/a><\/a><\/a><\/p>\r\n Now, the next step is to install Homebrew-Cask and per its sites installation notes, copy and paste the following command into a terminal window.<\/p>\r\n <\/a> <\/a><\/p>\r\n Great! \u00a0With the prerequisites complete, it’s time to install PowerShell Core 6.0.1. \u00a0Run the following command to do so and enter your password when prompted.<\/p>\r\n <\/a> <\/a> <\/a><\/p>\r\n Awesome! \u00a0Now, to launch a PowerShell session in macOS, enter the following in terminal.<\/p>\r\n <\/a><\/p>\r\n Within a PowerShell session, you can check the version of PowerShell by running the following.<\/p>\r\n <\/a><\/p>\r\n As new versions of\u00a0PowerShell are released, simply update the Homebrew formulae and update PowerShell by running the following commands in terminal.<\/p>\r\n While leveraging Homebrew is the recommended installation method, there are alternate methods as well. \u00a0For more information on that along with uninstallation commands, please see the following link<\/a>.<\/p>\r\n Congratulations! \u00a0You’ve successfully installed PowerShell Core 6.0.1 onto macOS! \u00a0Next comes the fun stuff for us VMware enthusiasts, installing VMware PowerCLI from the “PSGallery”. \u00a0Let’s continue!<\/p>\r\n Since VMware PowerCLI has moved from being its own native installer to the PSGallery, the PSGallery needs to be “Trusted” before anything from it can be installed. \u00a0To trust the PSGallery, entering the following command in the PowerShell session.<\/p>\r\n Note: This is optional and if it is skipped, you will be prompted to trust the gallery when entering the PowerCLI module install command<\/em><\/strong><\/span><\/p>\r\n <\/a><\/p>\r\n Next, run the following command to install the VMware.PowerCLI module. \u00a0This will find and install the latest version of the module available in the PSGallery<\/p>\r\n Note: Alternatively, you could set the “-Scope” parameter to “AllUsers” and if you wanted to install a different version you could use the “-RequiredVersion” parameter and specify the version number.<\/em><\/span><\/strong><\/p>\r\n <\/a> <\/a><\/p>\r\n Once this finishes, we can check to make sure the module is installed by running the following command.<\/p>\r\n <\/a><\/p>\r\n And if you’d like to see all of the VMware installed modules, run the following.<\/p>\r\n <\/a><\/p>\r\n As new versions of VMware.PowerCLI are released, you can run the following command to update it.<\/p>\r\n With VMware.PowerCLI now installed, you can connect to your vCenter Server or ESXi host and begin using its cmdlets to obtain information or automate tasks!<\/p>\r\n I went ahead and ran the following to ensure the module was imported. \u00a0<\/p>\r\n <\/a><\/p>\r\n I noticed one caveat, the SRM module does not seem to be supported in PowerShell Core, so I hope that gets resolved soon.<\/p>\r\n <\/a><\/p>\r\n Let’s test connecting to vCenter server…<\/p>\r\n I also noticed an error when running the above command stating that the “InvalidCertificateAction” setting was “Unset” and not supported.<\/p>\r\n <\/a><\/p>\r\n To bypass this, enter the following command and then enter “Y” when prompted. \u00a0This will set the parameter for the current user.<\/p>\r\n <\/a><\/p>\r\n Note: Alternatively, you can also use the “-Scope” parameter and enter “Session”, “User”, or “AllUsers” to apply the setting to those options respectively.<\/strong><\/em><\/span><\/p>\r\n Now, if we try to connect to vCenter again, we should be successful.<\/p>\r\n <\/a><\/p>\r\n Well, that about does it! \u00a0I hope that you have found this post useful and I thank you for stopping by and reading my content. \u00a0I’d like to give a shoutout to Mike White<\/a> for his post on the same topic. \u00a0Until next time!<\/p>\r\n -virtualex-<\/p>\r\n Pingbacks: Installing PowerShell\/PowerCLI on a Mac<\/a><\/p>\r\n\t
\/usr\/bin\/ruby -e \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/master\/install)\"<\/pre>\r\n
brew tap caskroom\/cask<\/pre>\r\n
brew cask install powershell<\/pre>\r\n
pwsh<\/pre>\r\n
$PSVersionTable.PSVersion<\/pre>\r\n
brew update\r\nbrew cask upgrade powershell<\/pre>\r\n
Set-PSRepository -Name \"PSGallery\" -InstallationPolicy \"Trusted\"<\/pre>\r\n
Find-Module \"VMware.PowerCLI\" | Install-Module -Scope \"CurrentUser\" -AllowClobber<\/pre>\r\n
Get-Module \"VMware.PowerCLI\" -ListAvailable | FT -Autosize<\/pre>\r\n
Get-Module \"VMware.*\" -ListAvailable | FT -Autosize<\/pre>\r\n
Update-Module \"VMware.PowerCLI\"<\/pre>\r\n
Import-Module \"VMware.PowerCLI\"<\/pre>\r\n
Connect-VIServer -Server \"<Server_Name><\/em>\"<\/pre>\r\n
Set-PowerCLIConfiguration -InvalidCertificateAction \"Ignore\"<\/pre>\r\n