Help with table data and Sync-UDElement

I am working on a page that allows you to search AD for a user, and once you select the user it will display information on the user object in a table.

Everything is working fine so far. Other than when the page first loads there is no data for the table to load and this causes an error to be displayed in the table. After you select a user the table data loads fine.

I am just wondering is there away to prevent the error from being displayed.

Here is my code.

Any suggestions on how I can suppress the error?

I would just check for null.

if ($null -ne $Session:GridData) {
        $Session:GridData | Out-UDTableData -Property @("DisplayName","UserName","EmployeeID","Email","Title","Department","AccountLocked","AccountExpired","AccountEnabled","PasswordExpired","PasswordLastSet","LastBadPasswordAttempt","LastLogonDate","AccountCreated")

Awesome! Thanks @adam! :grinning: