PowerShell Universal v4.0 Beta 1

PowerShell Universal

April 12, 2023

quote Discuss this Article

Today, we’re happy to announce the release of PowerShell Universal v4 Beta 1. This beta release follows many of the themes that we discussed in our last post.

You can download the beta directly from the PowerShell Universal downloads page.

Below, you’ll find the highlights.

APIs

Event Hubs

Event Hubs provide the ability to connect clients to the PowerShell Universal server. Once connected, the PowerShell Universal server can send messages to the connected clients and they will run a local PowerShell script block. Event Hubs can receive data from the server to process within the local script block.

Learn More

User Interfaces

Dashboards are now Apps

To better represent what a PowerShell Universal Dashboard is, we’ve decided to rename them to PowerShell Universal Apps. Long ago UD moved beyond being just dashboards and into something much more dynamic. With v4, we’ll now be referring to the feature as apps through out the documentation. Although some cmdlets have been renamed (e.g. New-UDDashboard is now New-UDApp), we’ve introduced aliases for any changes so your existing dashboards still work.

Learn More

Retiring of Pages

Pages provided a simple mechanism to create very basic interfaces. That said, it was a deviation from the rest of the product and didn’t provide the best user experience. After upgrade, existing pages will still function but you will no longer be able to edit or create them in the admin console. We will be taking much of what we learned from pages and implementing the best parts directly in apps.

Live App Docs

Every instance of PowerShell Universal now provides an extensive documentation app directly in the product. The docs are mostly built from the PowerShell help system and the examples come right from the cmdlets’ help. Examples can be interacted with and provide a much more complete demonstration of each of the components.

Some components are still a work in progress (e.g. New-UDDataGrid updates) but expect to see a very complete look at what you can do in an app. We will continue to improve this app and add examples as we work through the beta process. We’ll be adding an example for each new parameter or feature added. We also get the added benefit of utilizing this app for our own internal testing of apps. During the beta development, we increased our test coverage by about 5x using Playwright against the documentation app.

New and Updated Components

We’ve added several new components and cmdlets based on user feedback. Some of them include:

Automation

IValidateSetValuesGenerator Support

The admin console can now retrieve values from IValidateSetValuesGenerator classes. This interface allows for generating dynamic options for scripts. Using the example the above blog, you can define a generator in a PSU module.

using namespace System.Management.Automation

class ValidFilesGenerator : IValidateSetValuesGenerator {
    [string[]] GetValidValues() {
        $Values = (Get-ChildItem -File).Name
        return $Values
    }
}

Within your scripts, you can bring the module in and then take advantage of the generator in your ValidateSet attributes.

function Clear-FileInCurrentLocation {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
    param(
        [Parameter(Position = 0, Mandatory)]
        [ValidateSet( [ValidFilesGenerator] )]
        [string]
        $Path
    )

    Clear-Content -Path $Path
}

Platform

Health Checks

We’ve introduced a new diagnostic feature to better highlight issues that may be present with the instance of PSU. On an interval, PSU will run health checks on the system to validate that certain conditions are being met. Some of these currently include:

We will continue to extend this feature with new checks are we determine the highest impact checks to provide.

Logging

The logging framework is now much more configurable and extensible. By default, two log files will now be created. The first is the system scope log file. This file includes messages directly from the internals of PowerShell Universal such as the web server, configuration system and git sync processing. The second is for the user scope. This includes output from any scripts generated by the user from features such as APIs, Apps and jobs. We’ve also started to tag log messages with properties that dictate which feature and which resource are generating the log messages.

In addition to better categorizing log messages, we’ve also introduced a mechanism to configure logging targets for said messages. By default, the two file-based logging targets are configured as described above. You can add your own targets to receive log messages based on level, scope, feature and resource.

For example, you may want to define a log target for a single app. This example logs any messages generated by MyApp to the C:\logs\applog.txt file.

New-PSULoggingTarget -Type 'file' -FilePath 'C:\logs\applog.txt' -Scope User -Feature App -Resource 'MyApp'

The plan for v4 is the include the following built-in logging targets:

The PowerShell logging target allows you to define your own script blocks to write log messages are you please. The script block will receive the structure log event object as well as a rendered message string. We recommend limiting the scope of PowerShell logging targets to ensure good performance of your PowerShell Universal instances.

New-PSULoggingTarget -Type 'PowerShell' -Scope User -Feature App -Resource 'MyApp' -ScriptBlock {
    param($LogEvent, $Message)

    $Message | Out-File C:\logs\applog.txt
}

The next step for logging is to implement the database logging target and provide a log viewer within the admin console.

Updated Runtimes

We’ve updated PowerShell Universal to target .NET 7 an PowerShell 7.3. Using the integrated or agent environments will now take advantage of these versions.

Known Issues

We have several know issues with this beta build.

Beta Timeline

Please provide beta feedback on the forums or on GitHub. We will tag GitHub issues accordingly with the beta label. We are still targeting June 13th for the GA release of PowerShell Universal v4. Our next beta release will be on April 25th.

We’ve removed all license restrictions from the beta builds so you can test out all the new features without restriction.