[2.9.0] Updated and now a page is broken

12:59:33 [Warn] PowerShellExecutionService Error executing endpoint 2237c4d8-27a1-4603-ae73-1477afa1ab64. Method invocation failed because [Microsoft.ActiveDirectory.Management.ADUser] does not contain a method named ‘op_Addition’.

Is the error i am getting, that endpoint is the following code:


Hope one of you has an idea on why it started throwing this…

Does this happen when loading the page or when you click one of those buttons?

Loading the page, which is what throws me off.

Weird. I know this has been mentioned before but from my perspective, this syntax will run all these buttons on page load:

$detButton = New-UDButton -Text "Admin Lookup" -OnClick (Get-DetentionAdmin -subject $student)

While this syntax would run them when clicked:

$detButton = New-UDButton -Text "Admin Lookup" -OnClick { Get-DetentionAdmin -subject $student }

I just want to make sure we aren’t running the button code when the page is loading. Next version, I’m going to put the stack trace in the execution service so we can see what line this is coming from…

1 Like

So i swapped them all over to {} from ()

the page will load, however none of the buttons actually work. Clicking them does nothing and does not generate anything on:

Enable-UDLogging -Level warning -FilePath c:\scripts\log.log

The only thing i got in there was:

Enable-UDLogging -Level warning -FilePath c:\scripts\log.log

I am really stuck as to what is going on. The Functions are all defined as custom functions for the dashboard in a functions.ps1 file and initialized via

$addlog = New-UDEndpointInitialization -Function $functions -Variable @(“ConnectionString”, “gy”)
$dashboard = New-UDDashboard -LoginPage $LoginPage -Title $dashboardTitle -Theme $theme -Pages $Pages -Footer $footer -EndpointInitialization $addlog -Navigation $Navigation -AdminModeAuthorizationPolicy “ITPolicy”

Any help would be appreciated, cause this one has me stuck.

What’s in your $functions variable?

Can i email it to you? It would take me quite a bit of time to sterilize that file.

Is it the contents of a file? The -Function parameter should be a list of function names.

Try this:

. $Functions
$FunctionNames = @('Get-DetentionAdmin', 'New-Volunteer', 'etc') 

You could also make $Functions a module and then you wouldn’t have to specify each function name necessarily.

Import-Module 'MyFunctions.psm1'

$addlog = New-UDEndpointInitialization -Module "MyFunctions" -Variable @(“ConnectionString”, “gy”)
$dashboard = New-UDDashboard -LoginPage $LoginPage -Title $dashboardTitle -Theme $theme -Pages $Pages -Footer $footer -EndpointInitialization $addlog -Navigation $Navigation -AdminModeAuthorizationPolicy “ITPolicy”

$functions = @(“Add-Log”,

Each of those functions is defined in the functions.ps1 file.

Hmmm. yeah that is correct. I guess what’s weird is that you are getting no indication in the log that it’s even trying to execute the button.

Do you see any errors in the F12 developer tools in the browser after you click a button?

Nope, Though i did discover that when i clicked the Button for Set-DualEnrollment it was throwing that op_Addition error.

However still nothing shows up on the screen. Here is the code for Set-DualEnrollment (fixed to not throw that error):


Ok. I didn’t realize you were returning New-UDEndpoints from your functions. That’s why this syntax works:

$detButton = New-UDButton -Text "Admin Lookup" -OnClick (Get-DetentionAdmin -subject $student)

Now that you fixed that error, if you change back from {} to (), do you still see the error when loading up the page?

Nope, works fine now.

Is having those new-UDendpoints necessary? I know i had to have them back when i was adding all of this via Caching from AD and injecting them like this: https://hastebin.com/dokudimoba.pl

I never really considered removing the endpoints in there with this update where i stopped adding them as “attributes”

It’s usually not necessary. The reason to use New-UDEndpoint like this is in case you are having problems with scoping. I don’t think you would so you should be able to just return a script block from this function rather than a UDEndpoint.

Under the hood, UD is creating a UDEndpoint anyways. Using New-UDEndpoint just makes it more explicit and allows you to specify exactly which variables you’d like saved to the scope.