I’m in general interested in everything OfficeDevPnP but I’m not a developer. I like to think that I’m a Hacker, the old school “do something which wasn’t designed” type of hacker.
These days I’m experimenting with Docker and I wanted to play with the Office365-CLI and I thought why not run it from a Docker container. And maybe, just to make it more interesting run it from a Nano Server.
So these were my initial thoughts which lead to this blog post.
Reading the installation guide on GitHub I realized that I’ll need npm which means I need to install Node.js.
Ok, but how can I install the node.js on a Nano Server inside a container? It would be nice to have a package manager for Windows. Wait! There is one and it is called Chocolatey
I have to mention that you need to trust the author of the packages which might be not that easy for everyone.
Also, I bet other methods are exist to install the prerequisites and I’m just not aware.
- warm up the container
- install Chocolatey
- install node.js
- install git
- restart the container
- install Office365-CLI
- That’s it
docker run -i -t --name nano microsoft/powershell docker start nano docker exec -i -t nano pwsh
Trust me this is a Nano Server 2016
As I mentioned above Chocolatey will be our Package manager for Windows
Set-ExecutionPolicy Bypass -Scope Process -Force iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
It will give some errors because we are running it on PowerShell Core. It’s safe to ignore them.
Running the following commands the two prerequisite will be installed by Chocolatey.
You will need to consent during the installation, just hit
choco install nodejs.install choco install git.install
Because we haven’t created + started + connected just created + connected to the container when we exit - by typing in
exit - the container will automatically stop. So we just need to start it again and connect to it.
exit docker start nano docker exec -i -t nano pwsh
######Install Office365-CLI Lets install the CLI using npm.
npm i -g @pnp/office365-cli
After it was successfully installed you start using the CLI
If you find a bug in the CLI please report it on GitHub.