Learn various ways to interact with Windows Admin Center by using PowerShell.
Latest posts by Timothy Warner (see all)

Are you using Windows Admin Center (WAC) yet? If not, why not? This free Microsoft web-based utility represents the next generation of on-premises and cloud server management! Here, look:

Windows Admin Center

Windows Admin Center

The more recent WAC builds offer much more robust PowerShell support. And some PowerShell community members, chief among them Microsoft MVP Ravi Chaganti, develop useful PowerShell extensions to WAC's core functionality. Let's get started!

WAC and PowerShell DSC

You may want to require installation of WAC on some of your infrastructure servers. Why not enlist PowerShell Desired State Configuration (DSC) to assist you enforce this requirement?

The aforementioned Ravi Chaganti wrote a DSC resource module that, among other things, installs WAC on one or more nodes. You'll need to load Ravi's resources, download the WAC MSI package (easily done with a call to http://aka.ms/WACDownload), and place the file in a known location. After that, you can then write a configuration script similar to the following sample I ran on my test system (here's a link to the module docs):

Configuration WacSetup_SelfSignedCert
        [string[]]$ComputerName = 'localhost'

    Import-DscResource -ModuleName WindowsAdminCenterDsc

    Node $ComputerName
        WacSetup WacInstall {
            InstallerPath = 'C:\WindowsAdminCenter1904.1.msi'
            Ensure        = 'Present'

Other programmatic WAC installation methods

Microsoft keeps the current WAC version on the public Chocolatey package gallery. Therefore, you can use the native choco client or the PowerShell PackageManagement commands to install the software.

Use choco:

choco install windows-admin-center -y

Alternatively, use PowerShell:

Install-Package -Name windows-admin-center -Source chocolatey -Verbose

My friend and fellow 4sysops author Adam Bertram wrote a nice tutorial on installing WAC on Server Core systems. The long story short here is Adam uses the controversial Invoke-WebRequest cmdlet to fetch the WAC .msi file and then the msiexec command-line utility to orchestrate the installation.

WAC built-in utility scripts

Microsoft added "Show PowerShell" support in version 1806. If you didn't already know, WAC is largely a web-based front-end to a PowerShell function script library.

From any page in WAC, click View PowerShell scripts from the top toolbar to browse the script library; I show you this in the next figure.

WAC has a built in PowerShell function library

WAC has a built in PowerShell function library

Some of these functions might be useful to you outside of WAC. Simply choose a script from the drop-down, Ctrl+A to select all, and then Ctrl+C to copy the source code for Ctrl+V-ing into your development environment.

The PowerShell functions all deal in central Windows administration tasks, including:

  • Querying system hardware and software
  • Retrieving Hyper-V host and guest metadata
  • Obtaining Windows Server failover cluster information
  • Generating server inventories

Several contributors took the time to copy all the WAC functions and store them in a centrally cloneable GitHub repository; here is Paul DiMaggio's repo for your consideration. Note that Paul's repo is out-of-date—perhaps you could submit a pull request to Paul with the newest WAC functions?

PowerShell-based WAC management

WAC version 1812 added PowerShell support to manage WAC connections and extension feeds. Again, Ravi immediately "went there" by creating his PSWindowsAdminCenter module, available at the PowerShell Gallery. Let's install the module and view its enclosed functions:

Get-Command -Module 'PSWindowsAdminCenter' | Select-Object -Property Name, CommandType

Name                   CommandType
----                   -----------
Add-WacConnection         Function
Add-WacFeed               Function
Get-WacConnection         Function
Get-WacExtension          Function
Get-WacFeed               Function
Install-WacExtension      Function
Remove-WacConnection      Function
Remove-WacFeed            Function
Uninstall-WacExtension    Function
Update-WacExtension       Function

Let's see what we can do with Ravi's functions. Make sure to study the documentation as well.

First, we'll connect to a WAC host:

Add-WacConnection -GatewayEndpoint https://vm1 -ConnectionName vm1.timw.info -ConnectionType 'msft.sme.connection-type.server'

Second, we can retrieve connection details:

Get-WacConnection -GatewayEndpoint https://vm1 -ConnectionName vm1.timw.info

Third, we can get a list of all installed extensions from WAC:

Get-WacExtension -GatewayEndpoint https://vm1 -Status Installed

Last, we can install a new extension:

Install-WacExtension -GatewayEndpoint https://vm1 -ExtensionId 'ExtensionId'

Hopefully you see how potentially useful Ravi's PSWindowsAdminCenter module is. With it you can automate WAC connection (standalone and cluster) and extension/feed management.

Recently I learned that WAC Preview includes a PowerShell module that makes it simple to bulk export and import your connections. Here's the reference, and here's the code:

# Load the module
Import-Module "$env:ProgramFiles\windows admin center\PowerShell\Modules\ConnectionTools"
# Available cmdlets: Export-Connection, Import-Connection

# Export connections (including tags) to .csv files
Export-Connection "https://vm1" -fileName 'vm1-WAC-connections.csv'

# Import connections (including tags) from .csv files
Import-Connection "https://vm1" -fileName 'vm1-WAC-connections.csv'

WAC internal PowerShell console

Last but not least, I thought I'd mention that WAC has a built-in PowerShell console host. This is terrific news because it means we can leverage PowerShell management from anywhere in the world given we have (a) a web browser and (b) a secure connection to a WAC host.

WAC has its own PowerShell console

WAC has its own PowerShell console

Once you're at a PowerShell prompt, you can manage local and remote systems equally easily.

Subscribe to 4sysops newsletter!

In summary, I hope I've given you more to think about in terms of interacting with WAC with PowerShell. After all, WAC is largely a PowerShell host application!


Leave a reply

Your email address will not be published.


© 4sysops 2006 - 2023


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account