Using UDgrid to display servers within my Active directory enviornment

Happy New Year !

I recently tried to display my server list within AD with includes Operating System and server name and enabled status and ip address. However I cannot seem to get the IP address and Operating system to be displayed.


I went with the code below:

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

New-UDHeading -Text "Hello, World!" -Size 1

New-UdGrid -Title “Servers” -Headers @(“Name”, “OperatingSystem”, “Enabled”, “IPAddress”) -Properties @(“Name”, “OperatingSystem”, “Enabled”, “IPAddress”) -AutoRefresh -RefreshInterval 15 -Endpoint {

Get-ADComputer -Filter {OperatingSystem -like “Server”} | Out-UDGridData

Start-UDDashboard -Dashboard $Dashboardtest17 -Port 10003

###########################################################
Anything else I tried did not work so far I produced a react.js error.

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

New-UDHeading -Text "Hello, World!" -Size 1

New-UdGrid -Title “Servers” -Headers @(“Name”, “OperatingSystem”, “Enabled”, “IPAddress”) -Properties @(“Name”, “OperatingSystem”, “Enabled”, “IPAddress”) -AutoRefresh -RefreshInterval 15 -Endpoint {

Get-ADComputer -Filter {OperatingSystem -like “Server”} -Properties OperatingSystem,IPv4Address | select Name,OperatingSystem,Enabled,IPAddress | Out-UDGridData

This procduces an error also

$DashboardTest15 = New-UDDashboard -Title “Hello World” -NavBarColor ‘#5a595a’-NavBarFontColor ‘#535353’ -Content {

New-UDHeading -Text “Hello World” -Size 2

New-UDGrid -Title “Process Information” -Headers @(“Name”, “Operating System”, “Enabled”, “IPAddress”) -Properties @(“Name”, “OperatingSystem”, “Enabled”, “IPv4Address”) -Endpoint {

Get-ADComputer -Filter {OperatingSystem -like “Server”} -Properties OperatingSystem,IPv4Address |ForEach-Object {

[PSCustomObject] @{

                 "Name" = $_.Name

                 "Operating System" = $_.OperatingSystem

                 "IPAdresss" = $_.IPv4Address

             }

|Out-UDGridData

}

}

}

@admin24

Give this a try for your query and see if it is what you are looking for.

Get-ADComputer -Filter "OperatingSystem -like '*Server*'" -Properties OperatingSystem, IPV4Address

Also, in your code
New-UDGrid -Title “Process Information” -Headers @(“Name”, “Operating System”, “Enabled”, “IPAddress”) -Properties @(“Name”, “OperatingSystem”, “Enabled”, “IPv4Address”)

MAke sure the Properties match what the object is returning, in the top UDGrid you call IPAddress, but the bottom one you do it correct with IPv4Address and im not sure which one you are currently using.

Obie - Thank you very much for the -Properties suggestion.
However when I tried it the values don’t return and I get an error:

visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20{CliXml}&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

So mine works with this code…

$Dashboardtest17 = New-UDDashboard -Title “Hello, World!” -Content {
    New-UDHeading -Text "Hello, World!" -Size 1
    New-UdGrid -Title “Servers” -Headers @(“Name”, “OperatingSystem”, “Enabled”, “IPV4Address”) -Properties @(“Name”, “OperatingSystem”, “Enabled”, “IPV4Address”) -AutoRefresh -RefreshInterval 15 -Endpoint {
        Get-ADComputer -Filter "OperatingSystem -like '*Server*'" -Properties OperatingSystem, IPV4Address, Enabled | ForEach-Object {
        [PSCustomObject]@{
            'Name' = $_.Name
            'OperatingSystem' = $_.OperatingSystem
            'Enabled' = $_.Enabled
            'IPV4Address' = $_.IPV4Address
            }

        } | Out-UDGridData
    }
}
Start-UDDashboard -Dashboard $Dashboardtest17 -Port 8080 -Force

If you are still getting that reactjs error, it could be some sort of dependency or web browser issue rather than a Dashboard issue.

I have been messing with Grids a lot the past couple of weeks, and I believe you’ll need to fillow @Obie 's Paradigm here.

Now, taking a look at your code (please fix your markdown code blocks on your post, its extremely difficult to read) your Properties are

@(“Name”, “OperatingSystem”, “Enabled”, “IPv4Address”)

But your actual properties are Name, Operating System, and IPAddress

When you are calling this grid, you need to name the properties of the custom object you defined in order for it to actually work. In all honesty, I’m not sure how the enabled property is passing through based on your second code block.

To even further reduce your code, try this:

$DashboardTest15 = New-UDDashboard -Title 'Hello World' -NavBarColor '#5a595a'-NavBarFontColor '#535353' -Content {

  New-UDHeading -Text 'Hello World' -Size 2

  New-UDGrid -Title 'Process Information' -Headers @('Name', 'Operating System', 'Enabled', 'IP Address') -Properties @('Name', 'OperatingSystem', 'Enabled', 'IPv4Address') -Endpoint {

    ([pscustomobject]$(Get-ADComputer -Filter 'OperatingSystem -like "*server*"' -Properties OperatingSystem,IPv4Address,Enabled)) | 
    Select-Object Name,OperatingSystem,IPv4Address,Enabled | 
    Out-UDGridData

  }

}

Start-UDDashboard -Dashboard $DashboardTest15 -Port 10003

I just tested it, and it works…

Thank you very much @Obie and @rbleattler for your help.
I have tried both options and both worked ! ( see screenshot below)
I noticed that a few servers are set to false under the enabled column.
I would like to change the font color to red.

I was thinking about trying this:
$ActiveStatus = (Get-ADComputer -Filter “OperatingSystem -like ‘Server’” -Properties OperatingSystem,Enabled,IPV4Address)
if ($ActiveStatus.Enabled -eq “False”) {‘Write-Host -FontColor ‘red’ $ADInfo.Enabled’}``

What do you think is the best approach for this ?

Sorry about that I meant to put this below.

if ($ActiveStatus.Enabled -eq “False”) {‘Write-Host -FontColor ‘red’ $ActiveStatus.Enabled’}``

@admin24

I haven’t played with it personally… But check out this post from @adam

Probably get you going in the right direction

1 Like
New-UDGrid -Title " " -ID 'availabilitygrid' -AutoRefresh -RefreshInterval 250 -PageSize 10 -NoFilter -Endpoint {
                    $cache:status | Select-Object -First 6 | ForEach-Object {
                        $BgColor = '#8EA294'
                        $FontColor = '#E4EAED'
                        if ($_.'Status' -ne 'IN') {
                            $BgColor = '#63474D'
                            $FontColor = '#E4EAED'
                        }
                        [PSCustomObject]@{
                            'Name'   = New-UDElement -Tag 'div' -Attributes @{ style = @{ 'backgroundColor' = $BgColor; color = $fontColor } } -Content { $_.'Name' }
                            'Status' = New-UDElement -Tag 'div' -Attributes @{ style = @{ 'backgroundColor' = $BgColor; color = $fontColor } } -Content { $_.'Status' }
                        }
                    } |
                    Out-UDGridData
1 Like