PowerShell Universal
DownloadsIssuesDiscordForums
v1
v1
  • About
  • Get Started
    • Additional Resources
    • Installation
      • Docker
      • Upgrading
    • Licensing
    • System Requirements
    • Supported Browsers
    • Visual Studio Code Extension
  • Cmdlet Help
  • Examples
    • Active Directory
    • Hyper-V
    • Image Processing
    • Monitoring
    • PowerShell Protect
    • Slack
    • SQL
  • API
    • About
    • Development
    • Endpoints
    • Security
    • Error Handling
    • Rate Limiting
  • Automation
    • About
    • Development
    • Scripts
      • Parameters
    • Jobs
    • Schedules
    • Triggers
    • Variables
  • Dashboard
    • About
    • Development
    • Dashboards
      • Migrating From Universal Dashboard 2.9
      • Building Dashboards
      • Custom Variable Scopes
    • Frameworks
    • Components
      • Pages
      • Dynamic Regions
      • Element
      • Error Boundary
      • HTML
      • Building Custom Components
      • Data Display
        • Alert
        • Chip
        • Date and Time
        • Icon
        • List
        • Table
        • Tree View
        • Typography
      • Data Visualization
        • Charts
        • Map
      • Feedback
        • Backdrop
        • Modal
        • Progress
        • Skeleton
      • Inputs
        • Autocomplete
        • Button
        • Checkbox
        • Code Editor
        • Date Picker
        • Floating Action Button
        • Form
        • Radio
        • Select
        • Slider
        • Switch
        • Textbox
        • Time Picker
        • Upload
      • Navigation
        • Drawer
        • Stepper
        • Tabs
      • Layout
        • Grid Layout
        • Grid
        • Hidden
      • Utilities
        • Transitions
      • Surfaces
        • AppBar
        • Card
        • Paper
        • Expansion Panel
    • Interaction
    • Published Folders
    • Themes
      • Cascading Style Sheets
      • Styles
    • Scheduled Endpoints
    • Role Based Access
    • Marketplace
  • Platform
    • Cache
    • Monitoring
  • Configuration
    • About
    • API
    • Environments
    • Hosting
      • IIS
      • Single-File
    • Login Page
    • Management API
    • Settings
    • Security
      • App Tokens
      • OpenID Connect
      • WS-Federation
    • Running as a Service Account
    • Git
  • Debugging
    • Logging
    • Debugging Scripts
  • Changelog
  • Extension Changelog
  • Legacy Universal Dashboard Docs
Powered by GitBook

PowerShell Universal

  • Downloads
  • Pricing
  • Gallery

Community

  • Issues
  • Forums
  • Discord

Support

  • Portal
  • Knowledgebase

Copyright 2025 Ironman Software

On this page
  • Single File Hosting and Configuration
  • Installing
  • Configuration
  • Limitations
  • Referencing Other Files

Was this helpful?

Edit on Git
Export as PDF
  1. Configuration
  2. Hosting

Single-File

Single-file hosting and configuration for PowerShell Universal.

PreviousIISNextLogin Page

Last updated 4 years ago

Was this helpful?

Single File Hosting and Configuration

You can configure and run the PowerShell Universal server from the command line. The Start-PSUServer and Install-PSUServer cmdlets can be used to install, configure and run a Universal instance in a single file.

Installing

To install from the command line, use Install-PSUServer. By default, it will store the latest version of the PowerShell Universal Server to the $Env:ProgramData\PowerShellUniversal folder. You can specify an alternate path and optionally add the older to the $Env:Path environment variable .

Install-PSUServer -AddToPath

Once the server is installed, you can start it with Start-PSUServer.

Configuration

You can configure PowerShell Universal from the command line using Start-PSUServer and the -Configuration parameter. You can use the same cmdlets that you would use in the various configuration files but utilize a single file. You should save this file and then execute the PS1 file. Any changes to the file will be auto-reloaded.

Start-PSUServer -Port 8080 -Configuration {
    New-PSUEndpoint -Method GET -Url '/user' -Endpoint { "User1" }
    New-PSUEndpoint -Method POST -Url '/user' -Endpoint { $Body }
    New-PSUPublishedFolder -Path C:\images -RequestPath /images
    New-PSUDashboard  -Name 'Dashboard' -BaseUrl '/' -Framework "UniversalDashboard:Latest" -Content {
       New-UDDashboard -Title 'Test' -Content {
           New-UDTypography -Text 'Hello, world!'
       }
    }  
} -ExecutablePath "$Env:ProgramData\PowerShellUniversal\Universal.Server.exe"

Limitations

Single file hosting has some limitations in terms of scoping. Variables, functions and modules used within the parent scope or the configuration script block scope will not be accessible in the dashboard, endpoint or script content scopes.

$MyVariable = "Nice"

Start-PSUServer -Port 8080 -Configuration {
    # $MyVariable available here
    New-PSUEndpoint -Method GET -Url '/user' -Endpoint { 
        # $MyVariable not available here
    }
    New-PSUDashboard  -Name 'Dashboard' -BaseUrl '/' -Framework "UniversalDashboard:Latest" -Content {
       # $MyVariable not available here
       New-UDDashboard -Title 'Test' -Content {
           New-UDTypography -Text 'Hello, world!'
       }
    }  
}

You can work around these limitations by using variables and environments.

$MyVariable = "Nice"

Start-PSUServer -Port 8080 -Configuration {
    New-PSUVariable -Name 'MyVariable' -Value $MyVariable
    # $MyVariable available here
    New-PSUEndpoint -Method GET -Url '/user' -Endpoint { 
        # $MyVariable available here
    }
    New-PSUDashboard  -Name 'Dashboard' -BaseUrl '/' -Framework "UniversalDashboard:Latest" -Content {
       # $MyVariable available here
       New-UDDashboard -Title 'Test' -Content {
           New-UDTypography -Text 'Hello, world!'
       }
    }  
}

Referencing Other Files

The single-file hosting and configuration does not actually require the use of a single file. Rather, it means that you have a single entry point for the hosting and configuration of your PowerShell Universal server. You can reference other files within the -Configuration script block parameter.

For example, if you wanted to load endpoints from a nested folder, you could do the following.

Start-PSUServer -Port 8080 -Configuration {
    Get-ChildItem (Join-Path $PSScriptRoot 'endpoints') | ForEach-Object {
        & $_.FullPath
    }
}

With this configuration, you can have an endpoints folder within the same directory as your root file and they will be loaded automatically when the server starts of the files change.