EndpointInitialization Crashing IIS hosted UD

I think there might be an issue for this posted on github and the forums but my issue seems to differ a bit because after declaring some Function endpoints IIS just won’t start for me at all. I just get a 502 page and Application log events like below.

Error starting dashboard:
Cannot convert ‘System.Object’ to the type
‘System.Management.Automation.Runspaces.InitialSessionState’ required by parameter
‘EndpointInitialization’. Specified method is not supported.
at , C:\inetpub\wwwroot\dashboard.ps1: line 49
at , : line 1

Error starting dashboard:
Cannot bind parameter ‘Endpoint’. Cannot convert the
“System.Management.Automation.Runspaces.InitialSessionState” value of type
“System.Management.Automation.Runspaces.InitialSessionState” to type
“UniversalDashboard.Models.Endpoint”.
at , C:\inetpub\wwwroot\dashboard.ps1: line 58
at , : line 1

My Endpoints are just functions to do API calls back to Services tickets that will update notes or the statuses. I did make sure that in each endpoint file to include the New-UDEndpointInitialization -Function 'Function-Name' command.

I’m not sure where I went wrong in my dashboard file to cause IIS to not start. I left my Dashboard.ps1 file below any help would be greatly appreciated.

Dashboard and Page Creation

$Login = Get-ChildItem (Join-Path $PSScriptRoot 'Login') | ForEach-Object {
. $_.FullName
} 

$Pages = Get-ChildItem (Join-Path $PSScriptRoot "pages") | ForEach-Object {
. $_.FullName
}

$Endpoints = Get-ChildItem (Join-Path $PSScriptRoot 'endpoints') | ForEach-Object {
. $_.FullName
}

$Dashboard = New-UDDashboard -Title "IT" -Pages $Pages -EndpointInitialization $Endpoints -LoginPage $Login -NavBarColor '#FF1c1c1c' -NavBarFontColor "#FF55b3ff" -BackgroundColor "#550000" -FontColor "#FFFFFFF" -FontIconStyle FontAwesome -NavBarLogo (New-UDImage -Path "$PSScriptRoot\images\TAM-Logo-white.png" -Height 75 -Width 75) 

#  Log path
$DashboardName = "UD"
$DateString    = (Get-Date).ToString( 'yyyy-MM-dd.hh.mm' )
$DebugPath     = "$PSScriptRoot\Logs\Dashboard Logs\$DashboardName.Website.$DateString.Debug.log"

Enable-UDLogging -Level Debug -FilePath $DebugPath

Start-UDDashboard -Wait -Dashboard $Dashboard -Endpoint $Endpoints -AllowHttpForLogin

So the dashboard works fine when you don’t include the endpoint? If you have lots of functions as endpoints have you just tried using that in the script block instead of calling the file? I run in iis with endpoints but write the script in the script blocks not call the external file with endpoint

@psDevUK Thats correct when I run without using endpoint initialization cmdlet it runs perfect. Running the functions in the scriptblock was my next step to try so I guess I’ll give that shot and see how it goes. I would still like to figure out why it’s killing IIS though it’s so strange I followed and read all the documentation to a tee. But I’ve also got some plans to build a few dashboards that will require quite a few functions and it would be nice to have it all laid out nicer and not have functions all over the script blocks.

you are dumping the endpoints into the EndpointInitialization, and not the new-udendpointinitialization
-EndpointInitialization $Endpoints

Remove the “New-UDEndpointInitialization -Function ‘Function-Name’” from your endpoint files. and add it here:

$Login = Get-ChildItem (Join-Path $PSScriptRoot ‘Login’) | ForEach-Object {
. $_.FullName
}

$Pages = Get-ChildItem (Join-Path $PSScriptRoot “pages”) | ForEach-Object {
. $_.FullName
}

$Endpoints = Get-ChildItem (Join-Path $PSScriptRoot ‘endpoints’) | ForEach-Object {
. $_.FullName
}
$EndpointInitializaton = New-UDEndpointInitialization -Function ‘Function-Name’
$Dashboard = New-UDDashboard -Title “IT” -Pages $Pages -EndpointInitialization $EndpointInitializaton -LoginPage $Login -NavBarColor ‘#FF1c1c1c’ -NavBarFontColor “#FF55b3ff” -BackgroundColor “#550000” -FontColor “#FFFFFFF” -FontIconStyle FontAwesome -NavBarLogo (New-UDImage -Path “$PSScriptRoot\images\TAM-Logo-white.png” -Height 75 -Width 75)

Log path

$DashboardName = “UD”
$DateString = (Get-Date).ToString( ‘yyyy-MM-dd.hh.mm’ )
$DebugPath = “$PSScriptRoot\Logs\Dashboard Logs$DashboardName.Website.$DateString.Debug.log”

Enable-UDLogging -Level Debug -FilePath $DebugPath

sorry was looking this on my iphone @McAndersDK is spot on, so now I’m on a computer I use:-

Blockquote
$NavBarLinks = @((New-UDLink -Text “Visit Website” -Url “https://yoursite.com” -Icon medkit))
$Link = New-UDLink -Text ‘Your Website’ -Url ‘http://www.yoursite.co.uk’ -Icon globe
$Footer = New-UDFooter -Copyright ‘Designed by Me’ -Links $Link
$theme = New-UDTheme -Name “Basic” -Definition @{
‘.btn’ = @{
‘color’ = “#555555
‘background-color’ = “#f44336
}
‘.btn:hover’ = @{
‘color’ = “#ffffff
‘background-color’ = “#C70303
}
}
function invoke-something {
do-stuff
}
$Initialization = New-UDEndpointInitialization -Function ‘invoke-something’
$dashboard = New-UDDashboard -Title “MyTitle” -Pages (
$Homepage,
$page1,
$page2
) -NavbarLinks $NavBarLinks -Footer $Footer -EndpointInitialization $Initialization -Theme $theme
Start-UDDashboard -Wait -Dashboard (
$dashboard ) -Endpoint $Endpoint

and it works? :slight_smile: I dont see you populate the $endpoint variable with ur endpoints? :slight_smile:

So I’ve got it working and tested. The below code made my endpoints accessible from all of my dashboards. Thank you both for the replies and help.

Dashboard and Page Creation

    $Login = Get-ChildItem (Join-Path $PSScriptRoot 'Login') | ForEach-Object {
        . $_.FullName
    } 

    $Pages = Get-ChildItem (Join-Path $PSScriptRoot 'pages') | ForEach-Object {
        . $_.FullName
    }

    $Endpoints = Get-ChildItem (Join-Path $PSScriptRoot 'endpoints') | ForEach-Object {
        . $_.FullName
    }

    $EndpointInitializaton = New-UDEndpointInitialization -Function @("Add-request", "Add-SDNote", "Update-SDTick", "Add-Resolution")


    $Dashboard = New-UDDashboard -Title "Office of the Provost IT" -Pages $Pages -EndpointInitialization $EndpointInitializaton -LoginPage $Login -NavBarColor '#FF1c1c1c' -NavBarFontColor "#FF55b3ff" -BackgroundColor "#550000" -FontColor "#FFFFFFF" -FontIconStyle FontAwesome -NavBarLogo (New-UDImage -Path "$PSScriptRoot\images\TAM-Logo-white.png" -Height 75 -Width 75) 

    #  Log path
    $DashboardName = "UD"
    $DateString    = (Get-Date).ToString( 'yyyy-MM-dd.hh.mm' )
    $DebugPath     = "$PSScriptRoot\Logs\Dashboard Logs\$DashboardName.Website.$DateString.Debug.log"

    Enable-UDLogging -Level Debug -FilePath $DebugPath

    Start-UDDashboard -Wait -Dashboard ($Dashboard) -Endpoint $Endpoints -AllowHttpForLogin

thats awesome news @aggiebeckett glad you got it sorted

Well, I spoke too soon, it’s working on all but one dashboard currently and it’s the one I really wanted to implement some of the endpoints into… Can someone explain how the endpoints work in regards to having multiple cards with multiple inputs and endpoints on the same page? Currently, when trying to implement my initialized endpoints into this Tools Dashboard none of the endpoints seem to be running.

Here is one of the Tools I’m speaking of:

New-UDCard @Colors -Title "Add to Group - Single" -Content {
    New-UDInput @Colors -Title "Enter NetID and Group Name " -Endpoint {
        param($Target, $groupName, $requestid)

        if(-not ([string]::IsNullOrEmpty($Target)) -and -not ([string]::IsNullOrEmpty($groupName))) {
            $strDomain = "domain.local"
            $objCurrentDomain = New-Object System.DirectoryServices.DirectoryEntry                                
            #Target
            $objUserTarget = New-Object System.Security.Principal.NTAccount($strDomain, $Target)
            $strSIDTarget = $objUserTarget.Translate([System.Security.Principal.SecurityIdentifier])
            $strMemberTarget = "CN=" + $strSIDTarget.Value + ",CN=ForeignSecurityPrincipals," + $objCurrentDomain.distinguishedName
            $strTID = $Target | Out-String
            $dn = Get-ADGroup -Identity "$groupName" | select -Expand distinguishedName
            $group = New-Object DirectoryServices.DirectoryEntry("LDAP://$dn")
            [void]$group.member.Add("<SID=$strSIDTarget>")
            $group.CommitChanges()
            $group.Close()
            New-UDInputAction -Toast "Adding User $strTID to Group $groupName" -Duration 5000
            $tresults = Get-ADGroup -filter {name -like "*" -and member -eq $strMemberTarget}
            $ttable = New-UDTable @Colors -Title "New Group Membership for $strTID" -Headers @("Target Groups") -Endpoint {
            $tresults | Out-UDTableData -Property @("name")                                                                                       
        }
            #$ticnote = "User $strTID was added to Group $groupName"
            #Add-SDNote -requestid $requestid -note $ticnote 
            New-UDInputAction -Content $ttable
            Add-Content -Path $Cache:logpath -Value "$Cache:DateString - $User Added $Target to $groupName"
            

        }
        else {
            New-UDInputAction -Toast "Target or Group Name cannot be empty please enter a valid NetID and Group Name." 
        }
        $ticnote = "User $strTID was added to Group $groupName"
        Add-SDNote -requestid $requestid -note $ticnote
        Add-Content -Path $Cache:logpath -Value "Notes added to $requestid" 
    }               
} -Links @(
    New-UDLink -Text 'Reset' -Url 'Support-Dev-Tools'
)

Add-SDNote is the Function Endpoint I’m trying to call which adds notes to the specified Support Request via $requestid but currently any way I’ve tried the endpoint doesn’t seem to be working. As stated previously I have multiple UD-Cards that hold several of the tools in each card. Could that be causing the issues with calling my initialized endpoints?

Which user do the app pool run with? do it run with an account that are allowed to crawl AD ?

It’s a service account that has basically domain admin access minus a few permissions here and there. I should have mentioned all the tools run and return results without error its just the Initialized Endpoints I’m currently unable to run from within the these tools.

My guess is that the Initialized endpoints is only for the one you have in the start-uddashboard, and not in all endpoints in the “code”.

but im not sure.