Cant get a super basic dashboard up and running....What am i doing wrong?

Product: PowerShell Universal
Version: 1.4.6

Hi All,

I used to use the previous version of Universal Dashboard back when Start-UDDashboard -Port 8080 was a thing and was having a great time creating and testing out functionality of the module at the time.

I took a break from PowerShell scripting as i was tied up in other infrastructure projects and have returned to produce some dashboards for my company but I am completely at a loss with the new version and cant even get a basic dashboard to run.

The new UI looks great and I can find my way around but when it comes to creating a new dashboard, i really don’t understand where to begin? Using the documentation, i tried to add in some native PSCommandlets as a test but every one i have tried has failed?

The below for example doesn’t seem to work and the dashboard just crashes. I tried the same for Get-Process and Get-WMIObject and none of these native cmdlets work as I need them for my dashboard use cases.

> New-UDDashboard -Title "Hello, World!" -Content {
> 
>     Get-Service
> 
>     New-UDButton -Text "Click Me" -OnClick {
> 
>         Show-UDToast -Message 'Success!!'
> 
>     }
> 
> }

Sorry if I am being thick or am missing something but can someone please point me in the right direction as to how I can get this working?

And do we really have to use the built in code editor in the GUI as i prefer to edit and test my code using VSCode but every time i try and edit the .ps1 file of the dashboard i create in the GUI, again the dashboard crashes…

I have a paid license as i wanted to use full functionality but it seems im stuck at the first hurdle and cant move forward…

Any help will be greatly appreciated!

Hi @seeker2801!

Let’s get you up and running!

First off, this dashboard isn’t going to display what you like. To be fair, it wouldn’t display anything in UDv2 either. You’ll want to put your services into something like a table.

New-UDDashboard -Title "Hello, World!" -Content {
  New-UDTable -Data (Get-Service) 
  New-UDButton -Text "Click Me" -OnClick {
  Show-UDToast -Message 'Success!!'
 }
}

You also don’t need to edit in the web browser. You can open files in C:\ProgramData\UniversalAutomation\Repository. Any changes you make in there will be reflected in the admin console. It automatically reloads those files after they change.

One setting I’d suggest for your dashboard is auto-deploy. It will auto-reload the page as you make changes. No need to stop and start anything so it enables pretty rapid development.

We also have a VS Code extension you can use. It enables editing your PSU instance via the REST API. https://docs.powershelluniversal.com/visual-studio-code-extension#configuration

Some helpful modules to install might be Universal and UniversalDashboard. They will make developing easier because you’ll have intellisense.

Install-Module Universal
Install-Module UniversalDashboard
1 Like

Thanks @adam that seems to have done the trick. I think I can figure my way out from here!

1 Like

Hi Adam,

I am now facing an issue where if I try run the below as a simple test, i get the following error:

New-UDDashboard -Title “Hello, World!” -Content {

New-UDTable -Data (Get-Service -ComputerName SERVERNAME)

}

Error:

A parameter cannot be found that matches parameter name ‘ComputerName’

Do i need to do anything specific when working with remote computers?

Cheers

-ComputerName doesn’t exist on Get-Service in PS 7. You’ll need to change the environment your dashboard is running in to Windows Powershell 5.1

1 Like

Thanks @adam once again i greatly appreciate the help as that seems to have done it! I am however at another small roadblock.

I am using the cmdlet Get-Printer and the PrinterStatus property isn’t displaying as ‘Normal’ on the dashboard and is just showing blank. If I run this in ISE or wherever else, it shows as normal.

To test this, I changed the PrinterStatus property value of a printer from ‘Normal’ to ‘Good’ in ISE and this seems to work fine but when testing this in Universal, i get the error:

‘PrinterStatus’ is a ReadOnly property

However when i run:

$Printers.PrinterStatus.IsReadOnly, it returns $False.

Do you know what i may be missing regarding this? Just as a FYI, I am using the below to organise and create my columns:

New-UDTableColumn -Property PrinterStatus -Title “PrinterStatus”

Not sure if this makes a difference.

Cheers.

It looks like PrinterStatus is a Microsoft.PowerShell.Cmdletization.GeneratedTypes.Printer.PrinterStatus object. You’ll want to implement a render method for that column to return the string.

New-UDTableColumn -Property PrinterStatus -Title “PrinterStatus” -Render { $EventData.ToString() }