How to query exchange in dashboard

Ive been playing with how to do this. I just wanted to do something small like:

  • have a text box
  • user enters an email address to text field
  • user hits submit button
  • script grabs text input and queries exchange and returns something back to text box

How do i add import-module ExchangeOnlineManagement? I was testing with the dashboard.ps1 file and it seems to load the dashboard but when i hit submit, the dashboard logs just say something like “there was an error with the request”.

Maybe im importing the module at the wrong section? Should i be running a separate script that uses Start-UDDashboard and pass in the dashboard?

If you are using UDv2 (PS module from the gallery), you will need to use New-UDEndpointInitialization and add the module to that.

If you use PowerShell Universal, you won’t have to worry about this and it will import the module automatically in to the endpoints.

Do u have a sample piece of code where I would build the authentication piece? I have something like this…

Import-Module ExchangeOnlineManagement

New-UDDashboard -Title “Exchange Emails” -Content {

New-UDTextbox -Id 'email' -Label 'Email Address' -Value 'Enter an email address...'

New-UDButton -Icon (New-UDIcon -Icon check) -OnClick {

    Set-UDElement -Id 'email' -Properties @
        Value = "12234"
} -Text "Submit"