Issue with Out-UDGridData

Hi
This code does not appear to work . I get no results

New-UDPage -Name "DeviceDetails$($CollectionID)"  -Content {

    #Set current directory to SCCM site
    Push-Location
    Set-Location -Path $SCCMSiteCodePath
    $CollectionDetails = Get-CMCollectionDirectMembershipRule -Id $CollectionID
    pop-location
    $CollectionDetails | export-csv  -path "c:\temp\$CollectionID.CSV" -NoTypeInformation
    
        New-UdGrid -Title "$($CollectionID) Device Details" -Endpoint {
            $CollectionDetails| Out-UDGridData
        }
    }

If I put CollectionDetails into New-UdGrid -Title "($CollectionID) $CollectionDetails Device Details"
I can see my data
Also if I look at the CSV file
Now this one works

        New-UdGrid -Title "$CollectionName Deployment $DeploymentID Details - Last $Lasthours Hrs" -AutoRefresh -RefreshInterval 30 -Endpoint {
            Get-WDHBCMDeploymentDetailsSQL -AdvertisementID $DeploymentID -PackageID  $PackageID -ServerInstance $ServerInstance -Database $Database   -LastHours $LastHours |	
            Select-object Computername,ExecutionTime,Step,GroupName,ActionName,ExitCode,LastStatusMsgName,LastStatusMsgID |
            Sort-Object -Property Computername    |  Out-UDGridData 

I am wondering what I am doing wrong? or is there some properties that Out-UDGridData
cannot handle.
All i get reported on the page is no results

When you use -Content for the page, it is rendered when you run the cmdlet and not when the user visits the page.

What you can try is to use a dynamic page.

New-UDPage -Url "DeviceDetails/:CollectionID"  -Endpoint {
   param($CollectionId) 

    #Set current directory to SCCM site
    Push-Location
    Set-Location -Path $SCCMSiteCodePath
    $CollectionDetails = Get-CMCollectionDirectMembershipRule -Id $CollectionID
    pop-location
    $CollectionDetails | export-csv  -path "c:\temp\$CollectionID.CSV" -NoTypeInformation
    
        New-UdGrid -Title "$($CollectionID) Device Details" -Endpoint {
            $CollectionDetails| Out-UDGridData
        }
    }

Hi Adam,

What was missed off the original post was the fact it is a function that this running in

$SCCMOSDeploymentDeviceCollectionSubnavigation = @() $W10Deployments |Sort-Object | ForEach-Object { $Page = New-SCCMDeploymentCollectionDeviceDetailsPage -CollectionID $_.CollectionID -CollectionName $_.CollectionName $SCCMOSDeploymentDeviceCollectionSubnavigation += New-UDSideNavItem -Text $_.CollectionName -Url "DeviceDetails$($_.CollectionID)" $Pages += $Page }

function New-SCCMDeploymentCollectionDeviceDetailsPage {

Param
(
    [Parameter(Mandatory=$true,
               ValueFromPipelineByPropertyName=$true)]
    [String]$CollectionID,
    [Parameter(Mandatory=$true,
               ValueFromPipelineByPropertyName=$true)]
    [String]$CollectionName

)


New-UDPage -Name "DeviceDetails$($CollectionID)"  -Content {
    #Declare any variables that will be used as content inside cmdlets i.e. anything inside {} in a cmdlet
    #Then explicitly declare it as a Script Scope
    $Script:CollectionID = $CollectionID
    $Script:CollectionName = $CollectionName
    #Set current directory to SCCM site
    Push-Location
    Set-Location -Path $SCCMSiteCodePath
    #If a variable is going to be used that will be used as content inside cmdlet i.e. anything inside {} in a cmdlet
    #Then explicitly declare it as a Script Scope
    $Script:CollectionDetails = Get-CMCollectionDirectMembershipRule -Id $CollectionID
    pop-location
    $CollectionDetails | export-csv  -path "c:\temp\$CollectionID.CSV" -NoTypeInformation
    
        New-UdGrid -Title "Details of Devices in Collection $CollectionName ($($CollectionID) )" -Endpoint {
        $CollectionDetails| Select-Object -Property RuleName| Out-UDGridData            }
    }

}

What found was I had to declare the variables I wanted to use in the content with scope of Script to get it to work

Sorry about the formatting of the post, still trying to figure out how this forum works