{"id":1169,"date":"2018-03-04T13:27:18","date_gmt":"2018-03-04T18:27:18","guid":{"rendered":"https:\/\/ithinkvirtual.com\/?p=1169"},"modified":"2018-03-31T07:27:00","modified_gmt":"2018-03-31T11:27:00","slug":"install-powershell-and-vmware-powercli-on-centos","status":"publish","type":"post","link":"https:\/\/ithinkvirtual.com\/2018\/03\/04\/install-powershell-and-vmware-powercli-on-centos\/","title":{"rendered":"Install PowerShell and VMware PowerCLI on CentOS"},"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. \u00a0<\/p>\r\n

In my previous post<\/a>, I covered how to install those on to a macOS 10.13.x “High Sierra” system.\u00a0 In this post, I am going to show how to install both on to a CentOS 7 system as this is the distro I mostly use in my environments.\u00a0 I may follow this up with an Ubuntu install version.\u00a0 Anyway, let’s get to it!<\/p>\r\n

Note:\u00a0If you’re interested in installing this on other Linux distros, please consult the following link<\/a>.<\/strong><\/em><\/span><\/p>\r\n

There is a prerequisite needed before PowerShell can be installed on CentOS and that is to add the\u00a0PowerShell Core repository (recommended) to your CentOS system.<\/p>\r\n

sudo curl https:\/\/packages.microsoft.com\/config\/rhel\/7\/prod.repo | sudo tee \/etc\/yum.repos.d\/microsoft.repo<\/pre>\r\n

This will prompt you to enter your password since “sudo<\/em>“<\/em> is being used.\"\"<\/a> \"\"<\/a>Great! \u00a0With the prerequisite 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

sudo yum install -y powershell<\/pre>\r\n

\"\"<\/a> \"\"<\/a>Awesome! \u00a0Now, to launch a PowerShell session in CentOS, enter the following.<\/p>\r\n

pwsh<\/pre>\r\n

\"\"<\/a>Within a PowerShell session, you can check the version of PowerShell by running the following.<\/p>\r\n

$PSVersionTable.PSVersion<\/pre>\r\n

\"\"<\/a>As new versions of\u00a0PowerShell are released, simply update PowerShell by running the following command.<\/p>\r\n

sudo yum update -y powershell<\/pre>\r\n

While leveraging the PowerShell Core repository 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 CentOS! \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

Set-PSRepository -Name \"PSGallery\" -InstallationPolicy \"Trusted\"<\/pre>\r\n

\"\"<\/a>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

Find-Module \"VMware.PowerCLI\" | Install-Module -Scope \"CurrentUser\" -AllowClobber<\/pre>\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>Once this finishes, we can check to make sure the module is installed by running the following command.<\/p>\r\n

Get-Module \"VMware.PowerCLI\" -ListAvailable | FT -Autosize<\/pre>\r\n

\"\"<\/a>And if you’d like to see all of the VMware installed modules, run the following.<\/p>\r\n

Get-Module \"VMware.*\" -ListAvailable | FT -Autosize<\/pre>\r\n

\"\"<\/a>As new versions of VMware.PowerCLI are released, you can run the following command to update it.<\/p>\r\n

Update-Module \"VMware.PowerCLI\"<\/pre>\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

Import-Module \"VMware.PowerCLI\"<\/pre>\r\n

\"\"<\/a>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

Connect-VIServer -Server \"<Server_Name><\/em>\"<\/pre>\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>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

Set-PowerCLIConfiguration -InvalidCertificateAction \"Ignore\"<\/pre>\r\n

\"\"<\/a>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>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 Jim Jones<\/a> for his post on the same topic. \u00a0Until next time!<\/p>\r\n

-virtualex-<\/p>\r\n

Pingbacks: From Zero to PowerCLI: CentOS Edition<\/a><\/p>

<\/div>

<\/path><\/svg><\/i> \"Loading\"<\/p>

<\/div>","protected":false},"excerpt":{"rendered":"

Just a few days ago, PowerShell Core v6.0 was released for Windows, Linux, and macOS systems. \u00a0Alongside this release came the release of VMware PowerCLI 10.0.0.78953 which is VMware’s own “PowerShell-like” utility. \u00a0 In my previous post, I covered how to install those on to a macOS 10.13.x “High Sierra” system.\u00a0 In this post, I…<\/p>\n

<\/div>\n

<\/path><\/svg><\/i> \"Loading\"<\/p>\n

<\/div>\n","protected":false},"author":1,"featured_media":1187,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false,"jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[9],"tags":[35,11,27,33,23],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ithinkvirtual.com\/wp-content\/uploads\/2018\/03\/CentOS_PCLI_BG.png?fit=1024%2C573&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p7k0Z6-iR","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/posts\/1169"}],"collection":[{"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/comments?post=1169"}],"version-history":[{"count":0,"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/posts\/1169\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/media\/1187"}],"wp:attachment":[{"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/media?parent=1169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/categories?post=1169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ithinkvirtual.com\/wp-json\/wp\/v2\/tags?post=1169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}