Faster UD Dashboard Development with UDHotReloader



I love this.
I create a multi-file structure such as :

dashboard.ps1 (Start the dashboard file located in src/Root.ps1)

  • src
  • src/pages (Each page is a PS1 file in the pages folder)
  • src/Endpoints (Each endpoints is a PS1 file)

I had a small personal issue with the UDHotReloader because I couldn’t use it to update the endpoints the same way I was updating to the dashboard.

I came up with a solution for IIS where I use a modified UDHotReloader that will restart the designated web apppool instead of updating the dashboard when a file from the Endpoints folder is modified.

The core change is:

 if ($event.SourceEventArgs.FullPath -like '*\Endpoints\*' ) {
                    Restart-WebAppPool -Name $event.MessageData.AppPool
                } else {
                    Update-UDDashboard -Url $event.M$EessageData.Url -UpdateToken $event.MessageData.UpdateToken -FilePath $event.MessageData.Root

(You’ll also need to add the $Apppool variable to the function definition and to the MessageData of the Register-ObjectEvent section)

I am leaving the gist here for anyone interested:


I modified the function slightly again for a smoother experience.

I was bothered by the pace of update using the FileSystemWatcher directly because:

  1. It fires 2 events per change (at least for me)
  2. It fires so fast that I do not have the time to finish what I am writing (VSCode autosave as I type).
  3. If using the AppPool parameter for the endpoints, the webapp pool is restarted twice and too often (It is fast but as the dashboard get bigger, if there’s additional delay restarting the pool, you don’t want it twice per change and as instant.

I removed the update logic from the FileSystemWatcher event and instead added a 750ms timer there, which autoreset each time a file has changed, meaning 10 changes within 750 ms will trigger only one update, 750 ms after the last file change was registered.

The Update logic is now located in the Timer elapsed event.
You can customize the delay to whatever you like through $UpdateDelay parameter.

Good to note:
-Whenever Appool is recycled, the update-dashboard events done afterward won’t refresh your dashboard anymore until a manual refresh is done once. It does not affect regular updates.

Other changes:

  • If $AppPool is not specified, dashboard is updated normally so it can be used like the one Adam introduced for non-IIS workload

  • $EndpointsPath is the path where your endpoints files will be located and works with AppPool

    $UDHotParams = @{
    Root = ‘C:\Users\m\PoshUD-IIS\rest\src\root.ps1’
    UpdateToken = ‘test’
    Url = ‘
    AppPool = ‘PoshUD-IIS’ # If omitted (because not using IIS), it will simply update dashboard
    UpdateDelay = 500 # Default is 750 ms
    EndpointsPath = ‘*\Endpoints*’

    Start-UDHotReloader @UDHotParams
    I updated the gist in my previous post with this new version.