WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Apple / VMware Fusion Powershell community module

VMware Fusion Powershell community module

10.05.2017 by William Lam // 1 Comment

During the VMware Fusion 2017 Tech Preview, I was experimenting around with the new Fusion REST API and I had built a small prototype PowerShell Module as a way for me to learn how the API works. This allowed me to provide valuable feedback back to the Fusion Engineering team on improving the REST API UX. I was pleasantly happy to see that the majority of the feedback was indeed implemented for Fusion 10 which GA'ed a few weeks back.

Given the PowerShell module was pretty useful for my own use, I figure I would also publish it for others who might also be interested in Automating VM management using the new Fusion REST API, especially those with a PowerShell/PowerCLI background. Another nice thing about the module is that it can run across macOS/Linux via PowerShell Core or Windows using full blown PowerShell. I have been slowly tweaking the module to include the updated REST API changes and I am please to announce that the VMware.Hosted PowerShell Module which supports the new Fusion 10 REST API is now available!

The module includes the following 14 functions:

  • Connect-HostedServer
  • Disconnect-HostedServer
  • Get-HostedNetworks
  • Get-HostedVM
  • Get-HostedVMNic
  • Get-HostedVMSharedFolder
  • New-HostedVM
  • New-HostedVMSharedFolder
  • Remove-HostedVM
  • Remove-HostedVMSharedFolder
  • Resume-HostedVM
  • Start-HostedVM
  • Stop-HostedVM
  • Suspend-HostedVM


If you have ever used PowerCLI before, these functions should feel very familiar. We have basic Connect/Disconnect-HostedServer which will set an environmental variable called $DefaultHostedServer. This variable contains some basic information about the Fusion API endpoint as well as the base64 encoded credentials which are required when connecting to the new Fusion API. Below are a few examples using the new Fusion module, they are pretty basic and I have only implemented a sub-set of the Fusion REST API, so any community contributions are most welcome!

Lets connect to the Fusion 10 REST API endpoint remotely using the Connect-HostedServer function, which means HTTPS will need to be setup (see this blog post here for details):

Connect-HostedServer -Server 172.16.1.1 -Protocol https -Username vmware -Password 'VMw@re123'


Next, we can get a list of all VMs that are registered with our Fusion instance by using the Get-HostedVM function:

Get-HostedVM

To get more details about a specific VM, we can also pass in the VM's Id as shown in the screenshot:

Get-HostedVM -Id 1TS7DAP


Today, the REST API only allows for Cloning from an existing (poweredOff VM), so lets try that out using the New-HostedVM function which accepts the Id of an existing VM and the new name for the cloned VM:

New-HostedVM -ParentId 1tS7DAP -Name Photon-Clone

To power on the VM, we simply use the Start-HostedVM and passing in the Id of the VM:

Start-HostedVM -Id 1CW6DN

Now that the VM is powered on, we can retrieve more details such as the power state and the IP Address of the VM by running the Get-HostedVM function:

Get-HostedVM -Id 1CW6DN


I personally make use of the Shared Folders feature in Fusion, so I created a few functions to allow you to retrieve, configure and remove shared folders for a given VM.

To create a new shared folder mapping, we can use the New-HostedVMSharedFolder function and providing the Id of the VM, the name of the folder inside of the VM and the full host path that we wish to share within the VM:

New-HostedVMSharedFolder -Id 1CW6DN -FolderName Downloads -HostPath /Users/lamw/Downloads

As you can see in the example below, I created two shared folders and we can list all shared folders for a given VM by simply running:

New-HostedVMSharedFolder -Id 1CW6DN


Finally, we can also list all VM Networks that have been defined in Fusion and their configurations by using the Get-HostedNetworks command as shown in the screenshot below:


There are several other functions that I did not cover, but hopefully you will find that they are pretty easy and intuitive to use. Since this a community and non-official VMware module, if folks would like to contribute and add other functionality or even improve the current implementation, feel free to send me a pull request.

More from my site

  • VMware Fusion 2017 Tech Preview adds REST API support
  • Workspace One Access (vIDM) Powershell Module to automate creating 3rd Party Identity Provider
  • Managing Distributed Firewall Rules in VMC using PowerShell & NSX-T Policy API
  • Native OVF support for Fusion/Workstation 2017 Tech Preview 
  • Heads Up - Workaround for changing Mac OS X VM display resolution in vSphere & Fusion

Categories // Apple, Automation, Fusion, PowerCLI Tags // apple, fusion, powershell, PowerShellCore, REST API, vmrest

Comments

  1. *protectedColin Westwater says

    10/05/2017 at 7:37 am

    I hope the REST API will be available in Workstation at some point. I found a thread on VMTN that they hope it will come, so fingers crossed!

    Reply

Thanks for the comment!Cancel reply

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

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...