How to populate Client computer information

Hello,
I am very new to PoshUD and is slowly stumbling my way to make a dashboard for Helpdesk team. I want them to enter a computer name and be able to see its H/W information like Hard Disk space, Network info. This is what i have until now

$Pages = @()
$Pages += New-UDPage -Name “ComputerInfo” -Icon info_circle -Content {
New-UDInput -Content {
New-UDInputField -Name “ComputerName” -Type textarea -Placeholder “Enter the Computer Name”
} -Endpoint {
param ($ComputerName)
If (Test-WSMan -ComputerName $ComputerName){
$PSSession = New-CimSession -ComputerName $ComputerName
$LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -CimSession $PSSession
New-UDChart -Title “Disk Space” -Type Doughnut -RefreshInterval 20 -Endpoint {
try {
LogicalDisk | Where-Object {.DriveType -eq ‘3’} | Select-Object -First 1 -Property DeviceID,Size,FreeSpace | ForEach-Object {
@([PSCustomObject]@{
Label = “Used Space”
Data = [Math]::Round((_.Size -
.FreeSpace) / 1GB,2);
},
[PSCustomObject]@{
Label = “Free Space”
Data = [Math]::Round($_.FreeSpace / 1GB,2);
}) | Out-UDChartData -DataProperty “Data” -LabelProperty “Label” -BackgroundColor @("#80FF6B63","#8028E842") -HoverBackgroundColor @("#80FF6B63","#8028E842") -BorderColor @("#80FF6B63","#8028E842") -HoverBorderColor @("#F2675F","#68e87a")
}
}
catch {
0| Out-UDChartData -DataProperty “Data” -LabelProperty “Label”
}
}
}
Else {
Show-UDToast -Message “WSMan not enabled…” -Duration 100
}
}
}
$theme = Get-UDTheme ‘Azure’
$Dashboard = New-UDDashboard -Pages $Pages -Title “CustomerSupport ToolBox” -Theme $theme
Start-UDDashboard -Dashboard $dashboard -Port 1000 -AutoReload

It displays the toast message if WSMan is not working. Otherwise, nothing happens when i enter the computername and click Submit. Please provide guidance.

Thank you

Hey @shijilster,

Two things I notice.

  1. The first line in your Try block it looks like you are missing the “$” on the LogicalDisk before you Pipe it to find the drive.

  2. You seem to be drawing the table within the endpoint of the input, rather than replacing the form with the Table. If you are trying to keep the input there, then you would need to make a table within an Element then call to update that table after the Endpoint for the input is run.

I took some of your code to write a quick page, hopefully this gets your going in the right direction.

$Pages = @()
$Pages += New-UDPage -Name “ComputerInfo” -Icon info_circle -Content {
New-UDInput -Content {
    New-UDInputField -Name “ComputerName” -Type textarea -Placeholder “Enter the Computer Name”
    } -Endpoint {
        param ($ComputerName)
        If (Test-WSMan -ComputerName $ComputerName) {
            $PSSession = New-CimSession -ComputerName $ComputerName
            #$LogicalDisk = Get-CimInstance -ClassName Win32_LogicalDisk -CimSession $PSSession
            New-UDInputAction -Content @(
                New-UDTable -Title "Server Information" -Headers @(" ", " ") -Endpoint {
                @{
               'Computer Name' = $ComputerName
               'Operating System' = (Get-CimInstance -ClassName Win32_OperatingSystem).Caption
               'Total Disk Space (C:)' = (Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID='C:'" -CimSession $PSSession).Size / 1GB | ForEach-Object { "$([Math]::Round($_, 2)) GBs " }
               'Free Disk Space (C:)' = (Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID='C:'" -CimSession $PSSession).FreeSpace / 1GB | ForEach-Object { "$([Math]::Round($_, 2)) GBs " }
                }.GetEnumerator() | Out-UDTableData -Property @("Name", "Value")
            }
            )
        }
    }
}
$theme = Get-UDTheme ‘Azure’
$Dashboard = New-UDDashboard -Pages $Pages -Title “CustomerSupport ToolBox” -Theme $theme
Start-UDDashboard -Dashboard $dashboard -Port 1000 -AutoReload -Force
2 Likes

Thank you so much for your help!.. This will definitely push me in the right path!

1 Like