Output of command will not display on Dashboard dynamic page

#1

Hello,

I set to a RedirectUrl to point to a page I am making to grab services and display the accounts used to start them after filtering out LocalSystem, LocalService and NetworkService. The redirection works but there is no output. The Code:

New-UDInput -Title “Service Accounts - Please Enter Server Name” -Endpoint {
param($SName)
New-UDInputAction -RedirectUrl “/SvcAcct/$SName”

}

$Pages += New-UDPage -Url “/SvcAcct/:SName” -Endpoint {
param($SName)
$Services = Get-WmiObject -Class Win32_Service -ComputerName SName | Where-Object { .startname -ne “NT AUTHORITY\LocalService” -And _.startname -ne "NT AUTHORITY\NetworkService" -And .startname -ne “NT AUTHORITY\Network Service” } | Select-Object DisplayName, StartName
New-UDGrid -Title “Service Accounts” -Headers @(“DisplayName”, “StartName”) -Properties @(“DisplayName”, “StartName”) -AutoRefresh -Endpoint {
Services | ForEach-Object {[PSCustomObject]@{DisplayName = .DisplayName.ToString() ; StartName = $.StartName.ToString()}} | Out-UDGridData }

} 

The code that pulls the service data and created the PsCustomObject works fine standalone, but produces no output when fed to Out-UDGridData.

Note: There is supposed to be a dollar sign ($) wherever you see _.startname. It doesn’t come out when I send the text and I am not sure how to escape that character

#2

Try inserting a | Select-Object DisplayName,StartName before the Out-UDGridData.

#3

Larry,

If you indent your code one additional time–so that every line has at least one four-space tab at the beginning–before copying and pasting into your forum posts, it will be recognized as code and display better.

Thanks,
Tim Curwick