In a previous blog post from a far away history, I wrote about the WebCommander Fling (https://www.pascalswereld.nl/2013/10/30/webcommander/). Man that one is from 2013, I have been putting blog posts out there for a while now, hope you did find something useful on the blog…..
Anyhow back to this one. The WebCommander developer reached out in that previous post comment with a request to write-up a guide for WebCommander Walnut. I am writing it up as a walk-through to get it started and showing some output. If you would like some additions to the post, add some of the information your would like to see added to the post, or post questions / remarks and I will try to look if I can make some additions. But first….a little reminder about that commander out on the web…
What is WebCommander
WebCommander is a collection of web services around PowerShell and PowerCLI scripts. The interface can be used to provide users with scripts without them learning or knowing the PowerCLI commands. Or to give users access only to specific prepared tasks without giving them access to the web client (they still need to have permissions in the environment to do their operations). A great way in delegating specific tasks!
WebCommander was initially released and maintained as a VMware Fling. WebCommander was received very well by the community and saw the Fling being released as, and in turn moved to, an open source project on GitHub in 2014 (as announced on http://www.virtu-al.net/2014/09/03/webcommander-goes-open-source/).
The WebCommander project page can be found at: https://github.com/vmware/webcommander. This WebCommander version mainly uses XML with browser side transforming (XSLT). And when you hear version you know there might be another one, and yes there is WebCommander Walnut in a different branch.
WebCommander Walnut is to be used when :
- you prefer JSON over XML,
- combining commands in workflows for more or complex automation,
- run local or cloud scripts (WebCommander Hybrid),
- having a history,
- 64-bit PowerShell,
- more new features,
- and a new User Interface
Take a look at WebCommander Walnut for yourself, go to GitHub: https://github.com/9whirls/webcommander_walnut
Prepare the system:
Create a VM
Use Windows 2012R2 or Windows 2008R2 as the OS.
When using Windows2008R2 there are the following specifics:
- Install .Net Framework 4.5.2. Needed for the installation of PowerShell v5 on 2008R2
- Install PowerShell version 5
When using a fresh installation of Windows2012R2 install PowerShell Version 5.
For installation of the PowerShell version 5 install the Windows Management Framework 5.0 that can be downloaded as an update, or directly from https://www.microsoft.com/en-us/download/details.aspx?id=50395&ranMID=24542&ranEAID=TnL5HPStwNw&ranSiteID=TnL5HPStwNw-UGYM_0Jpr8QpSOcSBwTXfQ&tduid=(97816b302a22d507fcc1386696df4801)(256380)(2459594)(TnL5HPStwNw-UGYM_0Jpr8QpSOcSBwTXfQ)().
For Webcommander and PowerShell: Set-ExecutionPolicy Unrestricted -Force.
IIS Web-Server (including SubFeatures and Management Tools). Either use the Add Roles and Features GUI to install the Web Server role or use PowerShell:
Install-WindowsFeature Web-Server -IncludeManagementTools -IncludeAllSubFeature
PHP from https://php.iis.net. Click ‘Install PHP now’ from the web site to download the latest version. Execute the downloaded exe to start the Web Platform Installer. Continue the installer with all the default options (you can change by clicking the options link) and accept to do the installation. The installer will download and install the prerequisites.
And click Finish when done.
Install MongoDB for commands history.
In short the procedure for MongoDB is:
- Install Visual C++ Redistributable, you can get the 64-bit here: https://go.microsoft.com/fwlink/?LinkId=746572.
- Download community version at: https://www.mongodb.com/download-center#community.
It should offer you the correct release and OS.
- Install via the downloaded msi. Select complete or customize if you want. Complete will install in the default locations.
- Add the installation location as a system path environment. The default installation location is C:\Program Files\MongoDB\Server\3.4\bin.
- Use your powershell window used to install IIS or open a command prompt
- MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db. Create this folder using the following a command line
- Or use another location to suit your needs.
- MongoDB also requires a location to store logs. Create the log folder using command line
- Create a config file location with
- And add a text file mongodb.cfg there (watch the view – file extensions there!)
- Add the following to the cfg file and save:
systemLog: destination: file path: c:\data\log\mongod.log storage: dbPath: c:\data\db
- Install MongoDB as a Windows service by running mongod.exe with –install parameter (as administrator!).
mongod.exe --config "C:\data\conf\mongodb.cfg" --install
If you get api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer like this
your Windows updates either screwed up or you have to install Visual C++ Redistributable. (Re)installing Visual C++ will mostly do the trick.
- And now we will have a MongoDB service (use –serviceName and –serviceDisplayName to change to another name if you wish).
- Start the MongoDB service with net start MongoDB.
- Create database and collection in MongoDB for WebCommander by running the commands below:
- use webcmd
- Mongo should respond with “ok”:1
- Install the MongoDB powershell module:
- In PowerShellv5
- Accept the installation of required components.
Install latest version of VMware PowerCLI (version 6.5.1 at time of writing):
- Good thing is that version 6.5.1 does not require a msi installer anymore. You can install from the PowerShell Gallery via PowerShellGet (and the correct version of PowerShell, but we covered that one already):
- Use –Scope CurrentUser to use only for this user and no admin permissions required
Download the files from GitHub, for example for the zip file: https://github.com/9whirls/webcommander_walnut/archive/master.zip
Extract the zip and copy to c:\WebCommander. Or use your own location.
The Zip is composed of the following files and directories as subdirs of the master directory:
www/ – These are the files that need to be setup as the web service in IIS. _def is the file that is used to add the locations to the local scripts as defined in sources.json.
powershell/ …the local commands powershells
README.md – Readme file of the project
sources.json – Locations of local and remote scripts when wanting to use the remote script capability.
Note: that is, currently composed of… You never know what the future brings
Note: For scripts depending on your security policy Windows will normally block the files because they were downloaded from an external location, so you will have to unblock these files. Select the file – properties – and press the unblock in the security part at the bottom.
Open IIS Manager to configure the WebCommander site:
- Remove the default site
- Add a new site (in this case I used the administrator to connect as to know which user is running, don’t just copy but do what is appropriate for your environment)
- select the WebCommander site and open the authentication feature
- Enable Windows Authentication, and disable Anonymous.
- If we now open a browser we will see the initial page
When clicking on select a command we can only select the remote commands. use the source.json to define the local locations. For me it was fixed when removing http://localhost/ from the local configuration to read: “local” : “_def.json”,
This one could also help as the _def.json was also a bit empty. Go to c:\WebCommander\powershell\ and execute .\genDefJson.ps1 to recreate the definition json. We should use genDefJson when updating any ps1 scripts.
And voila local also shows up
Test drive WebCommander
There are scripts for vSphere actions and Horizon view actions distributed with the Git.
I have seen the following error message pop-up: AuthorizationManager check failed. The following is witnessed, and changed:
- For some reason the execution policy is back to restricted, Set-ExecutionPolicy RemoteSigned or Unrestricted.
- with the ExecutionPolicy set to RemoteSigned or Unrestricted, this error may occur if the script or some of the other included scripts is still blocked. From the explorer right-click the file, select Properties and click Unblock. Go through all the files!
Let see if we can get some vSphere information:
- Add Command vSphere (local)
- Add the required parameters, go to method to select what you want to do. I just want to see, so listDatastore is my option.
- And press the play
- Go to the output if there is a Pass
- And ….
If we want to get rid of the PowerCLI Customer Experience Improvement Program (CEIP) warning in the output. Run the following in Powershell:
Set-PowerCLIConfiguration -ParticipateInCEIP $false
(optionally with -Scope User / AllUsers)
And that’s it for now
– Enjoy WebCommanding throughout the universe!
Sources: labs.vmware.com, virtu-al.net, github.com/9whirls/webcommander_walnut