{"id":126224,"date":"2022-09-30T11:06:21","date_gmt":"2022-09-30T08:06:21","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=126224"},"modified":"2023-12-02T02:01:58","modified_gmt":"2023-12-01T23:01:58","slug":"install-vmware-powercli-tools-on-macos","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-vmware-powercli-tools-on-macos\/","title":{"rendered":"How To Install VMware PowerCLI Tools on macOS"},"content":{"rendered":"\n<p>VMware PowerCLI is a collection of <a href=\"https:\/\/computingforgeeks.com\/how-to-install-powershell-on-rhel-centos\/\">PowerShell<\/a> modules that provides <em>cmdlets<\/em> used to manage VMware environments. As a VMware Virtualization administrator, you&#8217;ll be able to perform most vSphere administrative tasks as well as automate many operations. A <strong><em>cmdlet<\/em><\/strong> is a lightweight command that <a href=\"https:\/\/computingforgeeks.com\/how-to-install-powershell-on-macos\/\">PowerShell<\/a> runtime invokes within the context of automation scripts that are provided at the command line. They are invoked programmatically through PowerShell APIs.<\/p>\n\n\n\n<p>The combination of VMware PowerCLI and PowerShell unlocks the power of automation more and more. PowerCLI provides an integration with VMware products such as vSphere ESXi, NSX, vCenter, vRealize Operations, VSAN, Horizon, and VMware Cloud platforms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install VMware PowerCLI Tools on macOS<\/h2>\n\n\n\n<p>The major requirement for this installation are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-family: Verdana, BlinkMacSystemFont, -apple-system, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; color: initial;\"><a href=\"https:\/\/en.wikipedia.org\/wiki\/PowerShell\" target=\"_blank\" rel=\"noreferrer noopener\">PowerShell<\/a><\/span><\/li>\n\n\n\n<li><a href=\"https:\/\/brew.sh\/\" target=\"_blank\" rel=\"noreferrer noopener\">Homebrew<\/a><\/li>\n\n\n\n<li>Internet connection<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Install Homebrew on macOS<\/h3>\n\n\n\n<p>If you don&#8217;t have Homebrew already installed on your system, run the commands below to download it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/bin\/bash -c \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)\"<\/code><\/pre>\n\n\n\n<p>Confirm installation was successful by checking the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">brew --version<\/mark>\nHomebrew 4.1.22-61-gee5f337\nHomebrew\/homebrew-core (git revision 12cb55611f0; last commit 2022-11-13)\nHomebrew\/homebrew-cask (git revision 1c6a8142ee; last commit 2022-11-13)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install PowerShell on macOS<\/h3>\n\n\n\n<p>With the Homebrew package installed, we&#8217;ll use it to get PowerShell on macOS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> brew install --cask powershell<\/mark>\n==> Downloading https:\/\/ghcr.io\/v2\/homebrew\/portable-ruby\/portable-ruby\/blobs\/sha256:02180ca8b8295422ae84921bcf034b7ee8ce5575488bd5e6a37a192e53cd5d34\n############################################################################################################################################################################################### 100.0%\n==> Pouring portable-ruby-3.1.4.el_capitan.bottle.tar.gz\n==> Downloading https:\/\/formulae.brew.sh\/api\/cask.jws.json\n############################################################################################################################################################################################### 100.0%\n==> Upgrading 1 outdated package:\npowershell 7.3.0 -> 7.4.0\n==> Upgrading powershell\n==> Caveats\nTo use Homebrew in PowerShell, set:\n  Add-Content -Path $PROFILE.CurrentUserAllHosts -Value '$(\/usr\/local\/bin\/brew shellenv) | Invoke-Expression'\n\n==> Downloading https:\/\/github.com\/PowerShell\/PowerShell\/releases\/download\/v7.4.0\/powershell-7.4.0-osx-x64.pkg\n==> Downloading from https:\/\/objects.githubusercontent.com\/github-production-release-asset-2e65be\/49609581\/24efc1e3-8b1d-412c-ba26-aa34b3775f3b?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=AKIA\n############################################################################################################################################################################################### 100.0%\n==> Downloading https:\/\/formulae.brew.sh\/api\/formula.jws.json\n############################################################################################################################################################################################### 100.0%\nAll formula dependencies satisfied.\n==> Uninstalling packages with sudo; the password may be necessary:\ncom.microsoft.powershell\nPassword:\n==> Running installer for powershell with sudo; the password may be necessary.\ninstaller: Package name is PowerShell - 7.4.0\ninstaller: Installing at base path \/\ninstaller: The install was successful.\n==> Purging files for version 7.3.0 of Cask powershell\n\ud83c\udf7a  powershell was successfully upgraded!<\/code><\/pre>\n\n\n\n<p>Verify that your installation is working properly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">pwsh<\/mark>\nPowerShell 7.4.0\nPS \/Users\/jkmutai><\/code><\/pre>\n\n\n\n<p>You can get a newer version of PowerShell by updating Homebrew&#8217;s formulae and upgrading PowerShell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew update\nbrew upgrade powershell --cask<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install VMware PowerCLI Tools on macOS<\/h3>\n\n\n\n<p>Open PowerShell on your macOS workstation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwsh<\/code><\/pre>\n\n\n\n<p>Then run the commands in PowerShell to install all&nbsp;PowerCLI&nbsp;modules:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Install-Module VMware.PowerCLI -Scope CurrentUser<\/mark><\/code><\/pre>\n\n\n\n<p>You may get a warning relating to modules installation from an <em>untrusted<\/em> repository, press&nbsp;<kbd><strong>Y<\/strong><\/kbd>&nbsp;or <strong><kbd>A<\/kbd><\/strong> to confirm the installation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Untrusted repository\nYou 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\ninstall the modules from 'PSGallery'?\n&#91;Y] Yes  &#91;A] Yes to All  &#91;N] No  &#91;L] No to All  &#91;S] Suspend  &#91;?] Help (default is \"N\"): <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\"><kbd>A<\/kbd><\/mark><\/code><\/pre>\n\n\n\n<p>The modules are downloaded automatically and stored in the correct folder. The&nbsp;<strong><em>-Scope<\/em><\/strong>&nbsp;parameter can be used to make the PowerCLI modules available to&nbsp;<strong><em>AllUsers<\/em><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Install-Module VMware.PowerCLI -Scope AllUsers<\/mark><\/code><\/pre>\n\n\n\n<p>To list all available modules, run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-Module -ListAvailable<\/code><\/pre>\n\n\n\n<p>On macOS the modules are stored inside <code>~\/.local\/share\/powershell\/Modules<\/code> directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls ~\/.local\/share\/powershell\/Modules<\/mark>\nVMware.CloudServices                                VMware.Sdk.vSphere.Content                          VMware.Sdk.vSphere.vCenter.TrustedInfrastructure\nVMware.DeployAutomation                             VMware.Sdk.vSphere.ContentLibrary                   VMware.Sdk.vSphere.vCenter.VCHA\nVMware.ImageBuilder                                 VMware.Sdk.vSphere.Esx.Hcl                          VMware.Sdk.vSphere.vCenter.Vm\nVMware.PowerCLI                                     VMware.Sdk.vSphere.Esx.Hosts                        VMware.Sdk.vSphere.vCenter.VmTemplate\nVMware.PowerCLI.Sdk                                 VMware.Sdk.vSphere.Esx.Settings                     VMware.Sdk.vSphere.vStats\nVMware.PowerCLI.Sdk.Types                           VMware.Sdk.vSphere.VAPI.Metadata                    VMware.Sdk.vSphereRuntime\nVMware.PowerCLI.VCenter                             VMware.Sdk.vSphere.vCenter                          VMware.Vim\nVMware.PowerCLI.VCenter.Types.ApplianceService      VMware.Sdk.vSphere.vCenter.Authentication           VMware.VimAutomation.Cis.Core\nVMware.PowerCLI.VCenter.Types.CertificateManagement VMware.Sdk.vSphere.vCenter.CertManagement           VMware.VimAutomation.Cloud\nVMware.Sdk.Nsx.Policy                               VMware.Sdk.vSphere.vCenter.Content                  VMware.VimAutomation.Common\nVMware.Sdk.Runtime                                  VMware.Sdk.vSphere.vCenter.Datastore                VMware.VimAutomation.Core\nVMware.Sdk.vSphere                                  VMware.Sdk.vSphere.vCenter.Deployment               VMware.VimAutomation.Hcx\nVMware.Sdk.vSphere.Appliance                        VMware.Sdk.vSphere.vCenter.Guest                    VMware.VimAutomation.HorizonView\nVMware.Sdk.vSphere.Appliance.Access                 VMware.Sdk.vSphere.vCenter.ISO                      VMware.VimAutomation.License\nVMware.Sdk.vSphere.Appliance.Health                 VMware.Sdk.vSphere.vCenter.Identity                 VMware.VimAutomation.Nsxt\nVMware.Sdk.vSphere.Appliance.InfraProfile           VMware.Sdk.vSphere.vCenter.Inventory                VMware.VimAutomation.Sdk\nVMware.Sdk.vSphere.Appliance.LocalAccounts          VMware.Sdk.vSphere.vCenter.LCM                      VMware.VimAutomation.Security\nVMware.Sdk.vSphere.Appliance.Logging                VMware.Sdk.vSphere.vCenter.NamespaceManagement      VMware.VimAutomation.Srm\nVMware.Sdk.vSphere.Appliance.Networking             VMware.Sdk.vSphere.vCenter.Namespaces               VMware.VimAutomation.Storage\nVMware.Sdk.vSphere.Appliance.Recovery               VMware.Sdk.vSphere.vCenter.OVF                      VMware.VimAutomation.StorageUtility\nVMware.Sdk.vSphere.Appliance.SupportBundle          VMware.Sdk.vSphere.vCenter.Services                 VMware.VimAutomation.Vds\nVMware.Sdk.vSphere.Appliance.System                 VMware.Sdk.vSphere.vCenter.Storage                  VMware.VimAutomation.Vmc\nVMware.Sdk.vSphere.Appliance.Update                 VMware.Sdk.vSphere.vCenter.SystemConfig             VMware.VimAutomation.WorkloadManagement\nVMware.Sdk.vSphere.Cis                              VMware.Sdk.vSphere.vCenter.Tagging                  VMware.VimAutomation.vROps\nVMware.Sdk.vSphere.Cis.Tagging                      VMware.Sdk.vSphere.vCenter.Topology                 VMware.VumAutomation<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">PowerCLI usage example<\/h2>\n\n\n\n<p>Let&#8217;s consider a simple example on using VMware vSphere cmdlets for automated administration of the vSphere environment. <\/p>\n\n\n\n<p>To get details about installed version of PowerCLI, use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Get-PowerCLIVersion<\/mark>\n\nPowerCLI Version\n----------------\n   VMware.PowerCLI 12.7.0 build 20091289\n---------------\nComponent Versions\n---------------\n   VMware Common PowerCLI Component 12.7 build 20067789\n   VMware Cis Core PowerCLI Component PowerCLI Component 12.6 build 19601368\n   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.7 build 20091293\n\n\nPS \/Users\/jkmutai&gt;<\/code><\/pre>\n\n\n\n<p>See current configuration before you proceed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> Get-PowerCLIConfiguration<\/mark>\n\nScope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout\n                                                                                                  Seconds\n-----    -----------     ------------------- ------------------------  -------------------------- -------------------\nSession  UseSystemProxy  Multiple            <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">Unset<\/mark>                     True                       300\nUser\nAllUsers<\/code><\/pre>\n\n\n\n<p>Update the configuration to ignore accept self-signed certificates for SSL connection:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Set-PowerCLIConfiguration -InvalidCertificateAction Ignore<\/mark>\n\nPerform operation?\nPerforming operation 'Update VMware.PowerCLI configuration.'?\n&#91;Y] Yes  &#91;A] Yes to All  &#91;N] No  &#91;L] No to All  &#91;S] Suspend  &#91;?] Help (default is \"Y\"): <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\"><kbd>A<\/kbd><\/mark>\n\nScope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout\n                                                                                                  Seconds\n-----    -----------     ------------------- ------------------------  -------------------------- -------------------\nSession  UseSystemProxy  Multiple            <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Ignore<\/mark>                    True                       300\nUser                                         Ignore\nAllUsers<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Connect to Environment<\/h3>\n\n\n\n<p>Use the&nbsp;<a href=\"https:\/\/developer.vmware.com\/docs\/powercli\/latest\/vmware.vimautomation.core\/commands\/connect-viserver\/\" target=\"_blank\" rel=\"noreferrer noopener\">Connect-VIServer<\/a>&nbsp;command to setup a new connection. This will ask you to input username and password.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Connect-VIServer -Server<\/mark><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"> esxi01.example.com<\/mark><\/em> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">-Protocol <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">https<\/mark>\n\nSpecify Credential\nPlease specify server credential\nUser: <strong><em>root<\/em><\/strong>\nPassword for user root: **********\n\n\nName                           Port  User\n----                           ----  ----\nesxi01.example.com             443   root<\/code><\/pre>\n\n\n\n<p>For non-interactive connection you can pass the username and password in CLI:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Connect-VIServer -Server<em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"> &lt;ServerIP_or_Hostname&gt;<\/mark><\/em> -Protocol <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">https<\/mark> -User <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">&lt;Username&gt;<\/mark> -Password <em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">&lt;Password&gt;<\/mark><\/em><\/code><\/pre>\n\n\n\n<p>Run a cmdlet to retrieve the <em>datastores<\/em> available.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Get-Datastore<\/mark>\n\nName                               FreeSpaceGB      CapacityGB\n----                               -----------      ----------\ndatastore1                             317.590         319.000<\/code><\/pre>\n\n\n\n<p>You can search for cmdlets commands using regex inPowerCLI, example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">#Show all cmdlets with keyword switch it its name\n<\/mark><\/em>PS \/Users\/jkmutai&gt; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">Get-VICommand *switch<\/mark>\n\nCommandType     Name                                               Version    Source\n-----------     ----                                               -------    ------\nCmdlet          Export-VDSwitch                                    12.7.0.20\u2026 VMware.VimAutomation.Vds\nCmdlet          Get-VDSwitch                                       12.7.0.20\u2026 VMware.VimAutomation.Vds\nCmdlet          Get-VirtualSwitch                                  12.7.0.20\u2026 VMware.VimAutomation.Core\nCmdlet          Initialize-CpuCoreConfigForEnhancedNetworkingStac\u2026 4.0.0.200\u2026 VMware.Sdk.Nsx.Policy\nCmdlet          Initialize-PreconfiguredHostSwitch                 4.0.0.200\u2026 VMware.Sdk.Nsx.Policy\nCmdlet          Initialize-RealizedLogicalSwitch                   4.0.0.200\u2026 VMware.Sdk.Nsx.Policy\nCmdlet          Initialize-StandardHostSwitch                      4.0.0.200\u2026 VMware.Sdk.Nsx.Policy\nCmdlet          New-VDSwitch                                       12.7.0.20\u2026 VMware.VimAutomation.Vds\nCmdlet          New-VirtualSwitch                                  12.7.0.20\u2026 VMware.VimAutomation.Core\nCmdlet          Remove-VDSwitch                                    12.7.0.20\u2026 VMware.VimAutomation.Vds\nCmdlet          Remove-VirtualSwitch                               12.7.0.20\u2026 VMware.VimAutomation.Core\nCmdlet          Set-VDSwitch                                       12.7.0.20\u2026 VMware.VimAutomation.Vds\nCmdlet          Set-VirtualSwitch                                  12.7.0.20\u2026 VMware.VimAutomation.Core<\/code><\/pre>\n\n\n\n<p>For more understanding on PowerCLI usage, refer to official VMware documentation pages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.vmware.com\/docs\/powercli\/latest\/products\/\" target=\"_blank\" rel=\"noreferrer noopener\">VMware PowerCLI Cmdlets by Product<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/vmware\/PowerCLI-Example-Scripts\" target=\"_blank\" rel=\"noreferrer noopener\">PowerCLI Community Scripts<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>VMware PowerCLI is a collection of PowerShell modules that provides cmdlets used to manage VMware environments. As a VMware Virtualization administrator, you&#8217;ll be able to perform most vSphere administrative tasks as well as automate many operations. A cmdlet is a lightweight command that PowerShell runtime invokes within the context of automation scripts that are provided &#8230; <a title=\"How To Install VMware PowerCLI Tools on macOS\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/install-vmware-powercli-tools-on-macos\/\" aria-label=\"Read more about How To Install VMware PowerCLI Tools on macOS\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":125491,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[329,299,320,86],"tags":[37884],"class_list":["post-126224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation","category-how-to","category-macos","category-virtualization","tag-vmware-powercli-tools-on-macos"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/126224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=126224"}],"version-history":[{"count":0,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/126224\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/125491"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=126224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=126224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=126224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}