Issue running example code

I haven’t had much luck getting things to run. Any idea why the code below won’t run? I get the attached error.

Stop all dashboards

Get-UDDashboard | Stop-UDDashboard

Grid

$PowerShellModuleFilesGrid = New-UdGrid -Title “PowerShell Module files” -Endpoint {
get-childitem -Path ‘C:\Program Files\WindowsPowerShell\Modules’ -Recurse | Select-Object -Property Name, Length | Out-UDGridData
} -AutoRefresh -RefreshInterval 5

The dashboard

$Dashboard1 = New-UDDashboard -Title “Servers dashboard” -Content{
# Dashboard layout
New-UDLayout -Columns 1 -Content {
$PowerShellModuleFilesGrid
}
}

Starting the dashboard

Start-UDDashboard -Port 5000 -Name “Servers” -Dashboard $Dashboard1

$files = get-childitem -Path ‘C:\Program Files\WindowsPowerShell\Modules’ -Recurse | Select-Object -Property Name, Length

Product: PowerShell Universal
Version: 2.5

Can you let me know where you found this example code? It’s from the old Universal Dashboard v2 but it looks like you are running PowerShell Universal.

The table has replaced the grid.

No need to call start dashboard or anything. That’s all managed in the admin console.

1 Like

Gotcha, I bought the Powershell Universal Dashboard course on Udemy.

One thing that is driving me nuts is the copy code functionality is not working. I go to paste and it doesn’t work. Even highlighting the code only works line by line.

What is wrong with this code? It should run right?

More examples that don’t work


Screen Shot 2021-11-12 at 6.08.23 PM

I did get this to work:

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

New-UDDynamic -Id 'table' -Content {
    $Data = Get-Process
    New-UDTable -Data $Data -Paging
    } -LoadingComponent {"Loading"}

New-UDButton -Text 'Refresh Table' -OnClick {
    
    Sync-UDElement -Id 'table'
}

$names = get-childitem | Select-Object Name
foreach($name in $names ){
$name
}

New-UDTable -Data $Names
}

The copy works in Safari but doesn’t in Firefox on Mac.

I can open a case with GitBook as they are the service we use for the docs.

1 Like