Getting PowerShell working on my Mac - via Docker

Currently - 7/23/17 - Powershell Beta 4 and PowerCLI 1.10 are not compatible.  But hopefully soon they will.  But since I want this to work now, we are going to get it working in a Docker container.  Thanks to Steve for the idea. I learned what to do between William Lam in this article, and the Docker site.

Docker

We get the Mac docker image from here. I am using the Community Edition.

Once we get the Docker image downloaded and double-click on it we see an easy install.

So we then start Docker (double + click on it in the Applications folder.

Next we see….

Next we see….

So now we start our Terminal app. And we try a few commands.

PowerCLI

From our Terminal, we use the following command to install PowerCLI.

docker pull vmware/powerclicore

And it does not take long to finish.

Now we need to run the PowerCLI Core Docker Container.

docker run -rm -it -entrypoint=’/usr/bin/powershell’ vmware/powerclicore

So we try a few commands. First:

Get-Module -ListAvailable PowerCLI*

Followed next by:

Connect-VIServer -server Lefroy.thewhites.ca

To help with the cert error you can use this command:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

Now we can connect to our vC again.

Connect-VIServer -server Lefroy.thewhites.ca

If you exit your terminal, and go in again, and start PowerShell you will be able to use PowerCLI fine.  Docker starts when you restart your computer and so you will be good.  But, if you quit Docker you won’t have PowerCLI.  If you start Docker again, you need to run the following command:

docker run -rm -it -entrypoint=’/usr/bin/powershell’ vmware/powerclicore

You will not have easy access to your scripts and so William has some examples of how to make them work in this article.  I wonder if there is an editor that I could find and than use copy and paste to it?  I think more work will be need to be done on this and for now will have to do interactive stuff.

BTW, I did not create a Docker account.  Not sure if I need to or not.

Once I figure out a good way to get access to my scripts I will add it to this article.

Questions or comments, let me know,

Michael

=== END ===

4 thoughts on “Getting PowerShell working on my Mac - via Docker

    1. Thanks JB, good info and yes, I might have to do that too. I think a really good solution will be when VMware updates it code. Then no need for docker.

      Michael

  1. Hey mate, good article. Just and FYI though- with Powershell being opensoruce now, you can run it natively on Mac (which I do now).

    1. Hi there,

      I would love to do that. But there is a version problem that prevents me. It is that VMware PowerCLI - which I need - is only compatible with the alpha PowerShell, and not the beta I installed. I hope that they (VMware) update their bits soon.

      Thanks for reading, and the comments!

      Michael

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.