### Start and Get Terminal Instances Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Get-PSUTerminalInstance.txt This example demonstrates how to start a new instance of a specific terminal configuration and then retrieve all currently running terminal instances. Ensure the terminal configuration 'Terminal1' exists before running. ```powershell $Terminal = Get-PSUTerminal | Where-Object Name -eq 'Terminal1' Start-PSUTerminalInstance -Terminal $Terminal Get-PSUTerminalInstance ``` -------------------------------- ### Get Command Help with Examples Source: https://github.com/ironmansoftware/universal-docs/blob/v5/intelligence/built-in-mcp-tools.md Retrieves help information for a specific command, with options to include full help text or just examples. Start with targeted help to avoid requesting excessive output. ```json { "module": "Universal", "command": "Invoke-PSUAiAgent", "parameter": "Prompt", "full": false, "examples": true } ``` -------------------------------- ### Install and Start PowerShell Universal on Linux Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/README.md Download the latest Linux x64 version, install unzip, extract the archive, make the server executable, and then run it. ```bash wget -O psu.zip https://powershelluniversal.com/download/psu/linux-x64/latest sudo apt install unzip unzip psu.zip -d PSU chmod +x ./PSU/Universal.Server ./PSU/Universal.Server ``` -------------------------------- ### Start an App by Name using Get-PSUApp Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-PSUApp.txt This example demonstrates how to start a specific app by piping the output of Get-PSUApp to Start-PSUApp. Ensure the app name 'MyApp' is valid in your PowerShell Universal instance. ```powershell PS C:\> Get-PSUApp -Name 'MyApp' | Start-PSUApp ``` -------------------------------- ### Start a Terminal Instance Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-PSUTerminalInstance.txt This example demonstrates how to start a new instance of a terminal named 'Terminal1'. First, it retrieves the terminal configuration using Get-PSUTerminal and filters it by name. Then, it passes the retrieved terminal object to Start-PSUTerminalInstance. ```powershell $Terminal = Get-PSUTerminal | Where-Object Name -eq 'Terminal1' Start-PSUTerminalInstance -Terminal $Terminal ``` -------------------------------- ### Start Server in Demo Mode Source: https://github.com/ironmansoftware/universal-docs/blob/v5/config/command-line-options.md The --mode demo option starts the PowerShell Universal server in a limited demo mode. ```bash Universal.Server.exe --mode demo ``` -------------------------------- ### Install Devolutions.PowerShellUniversal and Install-PSUServer Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/upgrading.md After removing the old server, uninstall and then reinstall the Devolutions.PowerShellUniversal module, followed by installing the PSUServer. This ensures a clean installation for MSI upgrades. ```powershell Uninstall-Module Devolutions.PowerShellUniversal Install-Module Devolutions.PowerShellUniversal Install-PSUServer ``` -------------------------------- ### Create a Simple GET Endpoint Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-PSUEndpoint.txt This example demonstrates how to create a basic GET endpoint that returns a static string. ```APIDOC ## POST /api/endpoints ### Description Creates a new API endpoint. ### Method POST ### Endpoint /api/endpoints ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **Url** (string) - Required - The URL path for the endpoint. - **Method** (string) - Required - The HTTP method for the endpoint (e.g., GET, POST). - **Endpoint** (script block) - Required - The script block to execute when the endpoint is called. - **AvailableInBranch** (string[]) - Optional - Specifies the branches where the endpoint is available. - **Credential** (string) - Optional - Credentials for the PowerShell Universal Management API. - **TrustCertificate** (SwitchParameter) - Optional - Ignores certificate issues. - **Disabled** (SwitchParameter) - Optional - Disables the endpoint. ### Request Example ```json { "Url": "/hello", "Method": "GET", "Endpoint": "{ 'Hello' }" } ``` ### Response #### Success Response (200) - **Id** (string) - The unique identifier of the created endpoint. #### Response Example ```json { "Id": "some-guid" } ``` ``` -------------------------------- ### Install-PSUServer Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Install-PSUServer.txt Installs the PowerShell Universal server. This function simplifies the installation process across Windows, Linux, and macOS. ```APIDOC ## Install-PSUServer ### Description Installs the PowerShell Universal server. This is a convenience function that will install the server for your platform. On Windows, it will install the server as a Windows service. On Linux, it will install the server as a systemd service. On Mac, it will install the server as a launchd service. ### Method Cmdlet ### Endpoint N/A (Cmdlet) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **Path** (String) - Optional - The path to store the PowerShell Universal binaries. If not specified, the default installation path will be used. - **Version** (String) - Optional - The version of PowerShell Universal to install. Defaults to the currently installed version if available. - **LatestVersion** (SwitchParameter) - Optional - Install the most recent version. - **IISWebsite** (String) - Optional - Specifies the IIS website to use for the PowerShell Universal installation. - **IISAppPool** (String) - Optional - Specifies the IIS Application Pool to use. Defaults to 'PowerShellUniversal'. - **IISPort** (Int32) - Optional - Specifies the port for the IIS website. Defaults to 0 (dynamic). - **CommonParameters** - Supports common PowerShell parameters like Verbose, Debug, ErrorAction, etc. ### Request Example ```powershell Install-PSUServer -Path "C:\Program Files\PowerShell Universal" -Version "2.0.0" Install-PSUServer -LatestVersion -IISWebsite "UniversalServer" -IISAppPool "PSUAppPool" -IISPort 8080 ``` ### Response #### Success Response (N/A for Cmdlet) Cmdlet execution success or failure. #### Response Example (Cmdlet output varies based on success or failure) ``` -------------------------------- ### Start-PSUServer Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-PSUServer.txt Starts the PowerShell Universal server. This cmdlet performs discovery and configuration of the Universal.Server executable. It uses Start-Process to start up the server after the configuration has been completed. This cmdlet requires that it can find the Universal.Server executable. You can use Install-PSUServer to download the proper binaries for your system. ```APIDOC ## Start-PSUServer ### Description Starts the PowerShell Universal server. This cmdlet performs discovery and configuration of the Universal.Server executable. It uses Start-Process to start up the server after the configuration has been completed. This cmdlet requires that it can find the Universal.Server executable. You can use Install-PSUServer to download the proper binaries for your system. ### Method START ### Endpoint / ### Parameters #### Path Parameters None #### Query Parameters * **-ExecutablePath** (String) - Optional - The path to the Universal.Server executable. This defaults to $Env:ProgramData\Universal.Server. If not found in this location, Start-PSUServer will also search the $ENV:PATH * **-ListenAddress** (String) - Optional - The address to listen on. For example: http://*:4000 * **-Configuration** (ScriptBlock) - Optional - A configuration script block. This enables single-file configuration. * **-Port** (Int32) - Optional - A port to listen on. ### Request Example ```powershell Start-PSUServer -Port 8080 ``` ### Response #### Success Response (200) * **Output** (System.Object) - The output of the server start process. #### Response Example ```powershell # Server started successfully. No specific output is typically returned on success. ``` ### Error Handling * **CommonParameters** - Supports common parameters like Verbose, Debug, ErrorAction, etc. ### Related Links * Install-PSUServer ``` -------------------------------- ### Slide Transition Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/utilities/transitions.md This example demonstrates a slide transition with a specified direction. Control the animation using `Set-UDElement`. ```powershell New-UDTransition -Id 'test' -Content { New-UDCard -Text "Hey" } -In -Slide -SlideDirection 'left' -Timeout 1000 New-UDSwitch -OnChange { Set-UDElement -Id 'test' -Properties @{ in = $EventData -eq 'True' } } -Checked $true ``` -------------------------------- ### Start PowerShell Universal Server on Windows Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/README.md Unzip the downloaded archive, unblock the files, and then execute Universal.Server.exe to start the PowerShell Universal server. ```powershell Expand-Archive -Path .\Universal.zip -DestinationPath .\Universal Get-ChildItem .\Universal -Recurse | Unblock-File Start-Process .\Universal\Universal.Server.exe ``` -------------------------------- ### Start-PSUDashboard Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-PSUDashboard.txt Starts an app (dashboard) in PowerShell Universal. This cmdlet can start a dashboard by providing the dashboard object or by its name. ```APIDOC ## Start-PSUDashboard ### Description Starts an app in PowerShell Universal. ### Method POST ### Endpoint /api/dashboard/{name} ### Parameters #### Path Parameters - **name** (String) - Required - The name of the app to start. #### Query Parameters - **appToken** (String) - Optional - The AppToken that is used for calling the PowerShell Universal Management API. - **computerName** (String) - Optional - Specifies the computer name or URL that should be called when accessing the PowerShell Universal Management API. - **integrated** (SwitchParameter) - Optional - Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal. - **useDefaultCredentials** (SwitchParameter) - Optional - Use default credentials when connecting to the management API. - **credential** (PSCredential) - Optional - Credentials to login to the PowerShell Universal Management API. - **trustCertificate** (SwitchParameter) - Optional - Whether the cmdlet should ignore certificate issues. #### Request Body - **app** (Dashboard) - Required - The dashboard object to start. ### Request Example ```json { "app": { "name": "MyApp", "scriptPath": "C:\\Scripts\\MyApp.ps1" } } ``` ### Response #### Success Response (200) - **status** (String) - Indicates the success of the operation. #### Response Example ```json { "status": "Dashboard 'MyApp' started successfully." } ``` ### Notes - Start-PSUDashboard is an alias for Start-PSUApp. - The `-App` parameter accepts pipeline input. ### Related Links - Connect-PSUServer - Get-PSUApp ``` -------------------------------- ### Endpoint Documentation with Comment-Based Help Source: https://github.com/ironmansoftware/universal-docs/blob/v5/api/openapi.md This example demonstrates how to document a simple GET endpoint using comment-based help in PowerShell. The SYNOPSIS, DESCRIPTION, and PARAMETER sections are used to generate OpenAPI documentation. ```APIDOC ## GET /get/:id ### Description Retrieves a resource by its ID. ### Method GET ### Endpoint /get/:id ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the resource to retrieve. ### Request Example (No request body for this example) ### Response #### Success Response (200) - **message** (string) - A success message. #### Response Example ```json { "message": "Resource retrieved successfully" } ``` ``` -------------------------------- ### Start a Dashboard App by Name Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-PSUDashboard.txt Starts the 'MyApp' app in PowerShell Universal by piping the output of Get-PSUApp to Start-PSUDashboard. Ensure the app exists before running. ```powershell PS C:\> Get-PSUApp -Name 'MyApp' | Start-PSUDashboard ``` -------------------------------- ### Invoke-PSUCommand Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Invoke-PSUCommand.txt This example demonstrates how to send an event to the 'MyHub' event hub using Invoke-PSUCommand. All connected clients will receive the event. ```powershell Invoke-PSUCommand -Hub 'MyHub' -Data @{ Name = 'Adam' } ``` -------------------------------- ### Create a New App with a Button Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/building-dashboards.md Creates a new app with a button that displays a toast message when clicked. This is a basic example to get started with app creation. ```powershell New-UDApp -Content { New-UDButton -Text 'Click Me' -OnClick { Show-UDToast "Ouch!" } } ``` -------------------------------- ### Install PowerShell Universal on macOS Source: https://github.com/ironmansoftware/universal-docs/blob/v5/get-started.md Installs the PowerShell Universal module and server on macOS, adding it to the system path and starting the server on port 5000. ```powershell Install-Module Devolutions.PowerShellUniversal Install-PSUServer -AddToPath Start-PSUServer -Port 5000 ``` -------------------------------- ### Create a Basic Backdrop Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/feedback/backdrop.md Use New-UDBackdrop to create an overlay. Include content within the -Content parameter. Use the -Open switch to display it. ```powershell New-UDBackdrop -Content { New-UDTypography -Text "Loading..." -Variant h2 } -Open ``` -------------------------------- ### Create a Server Started Trigger Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-PSUTrigger.txt Creates a new trigger that executes the 'LogServerStart.ps1' file when the PowerShell Universal server starts. This is useful for initial setup tasks or logging server availability. ```powershell New-PSUTrigger -Name 'Server Started' -EventType ServerStarted -TriggerScript 'LogServerStart.ps1' ``` -------------------------------- ### GET /api/v1/status Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-PSUDashboard.txt This endpoint returns the status of the application. It will return a 500 error if the app did not start. ```APIDOC ## GET /api/v1/status ### Description This endpoint returns the status of the application. It will return a 500 error if the app did not start. ### Method GET ### Endpoint /api/v1/status ### Parameters #### Query Parameters - **Required** (boolean) - Optional - Indicates if the parameter is required. - **Position** (string) - Optional - Specifies the position of the parameter (e.g., 'named'). - **Default value** (boolean) - Optional - The default value if not provided. - **Accept pipeline input** (boolean) - Optional - Whether the parameter accepts pipeline input. - **Aliases** (string) - Optional - Aliases for the parameter. - **Accept wildcard characters** (boolean) - Optional - Whether the parameter accepts wildcard characters. ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the application. #### Error Response (500) - **error** (string) - Description of the error if the app did not start. #### Response Example ```json { "status": "running" } ``` ``` -------------------------------- ### Zoom Transition Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/utilities/transitions.md Implement a zoom transition for components. The `Set-UDElement` cmdlet allows dynamic control over the transition's visibility. ```powershell New-UDTransition -Id 'test' -Content { New-UDCard -Text "Hey" } -In -Zoom -Timeout 1000 New-UDSwitch -OnChange { Set-UDElement -Id 'test' -Properties @{ in = $EventData -eq 'True' } } -Checked $true ``` -------------------------------- ### New-UDButton - All Parameters Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDButton.txt A comprehensive example showcasing the usage of most parameters available for New-UDButton. ```APIDOC ## New-UDButton - All Parameters ### Description Demonstrates the creation of a button utilizing a wide range of available parameters for customization. ### Method Cmdlet ### Endpoint N/A (Cmdlet) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```powershell New-UDButton -Text "Advanced Button" -Icon (New-UDIcon -Icon "star") -Variant "text" -IconAlignment "right" -FullWidth -OnClick { Write-Host "Advanced button clicked!" } -Size "large" -Style @{ "background-color" = "lightblue" } -Href "#" -Target "_self" -Id "my-custom-button" -Color "secondary" -Disabled -ClassName "my-button-class" -ShowLoading -LoadingIndicator (New-UDProgress -Value 50) -LoadingPosition "center" ``` ### Response #### Success Response (200) Represents the created button element. #### Response Example (Output is a UI element, not a JSON object) ``` -------------------------------- ### Get Pipeline Output by Job Object Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Get-PSUJobPipelineOutput.txt This example shows how to first retrieve a job object using Get-UAJob and then pass that object to Get-UAJobPipelineOutput to get its pipeline output. This method is useful when you already have the job object in a variable. ```powershell $Job = Get-UAJob -Id 12 Get-UAJobPipelineOutput -Job $Job ``` -------------------------------- ### Basic Grid Layout Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/layout/grid.md Demonstrates a basic responsive grid layout using New-UDGrid. It defines items with different column spans for extra-small screen sizes. ```powershell New-UDGrid -Container -Content { New-UDGrid -Item -ExtraSmallSize 12 -Content { New-UDPaper -Content { "xs-12" } -Elevation 2 } New-UDGrid -Item -ExtraSmallSize 6 -Content { New-UDPaper -Content { "xs-6" } -Elevation 2 } New-UDGrid -Item -ExtraSmallSize 6 -Content { New-UDPaper -Content { "xs-6" } -Elevation 2 } New-UDGrid -Item -ExtraSmallSize 3 -Content { New-UDPaper -Content { "xs-3" } -Elevation 2 } New-UDGrid -Item -ExtraSmallSize 3 -Content { New-UDPaper -Content { "xs-3" } -Elevation 2 } New-UDGrid -Item -ExtraSmallSize 3 -Content { New-UDPaper -Content { "xs-3" } -Elevation 2 } New-UDGrid -Item -ExtraSmallSize 3 -Content { New-UDPaper -Content { "xs-3" } -Elevation 2 } } ``` -------------------------------- ### Create Basic Data Grid with Columns Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDDataGrid.txt This example demonstrates how to create a basic data grid with specified columns. Ensure the data structure matches the defined columns. ```powershell PS >New-UDDataGrid -LoadRows { $Data = @( @{ Name = 'Adam'; Number = Get-Random} @{ Name = 'Tom'; Number = Get-Random} @{ Name = 'Sarah'; Number = Get-Random} ) @{ rows = $Data rowCount = $Data.Length } } -Columns @( New-UDDataGridColumn -Field 'Name' New-UDDataGridColumn -Field 'Number' ) -Id 'dataGrid1' ``` -------------------------------- ### Start PowerShell Universal Server with Single-File Configuration Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-PSUServer.txt Starts the PowerShell Universal server on port 8080 and applies a configuration defined within a script block. This configuration sets up a new GET endpoint at '/test' that returns 'Hi'. ```powershell Start-PSUServer -Port 8080 -Configuration { New-PSUEndpoint -Url '/test' -Method 'GET' -Endpoint { "Hi" } } ``` -------------------------------- ### Get Job Parameters by Run ID Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Get-PSUJobParameter.txt Retrieves the parameters for a job using its Run ID (GUID). Requires the JobRunId experimental feature. ```APIDOC ## GET /api/jobs/runs/{runId}/parameters ### Description Retrieves the parameters for a job using its Run ID (GUID). Requires the JobRunId experimental feature. ### Method GET ### Endpoint /api/jobs/runs/{runId}/parameters ### Parameters #### Path Parameters - **runId** (Guid) - Required - The run ID (GUID) for this job. #### Query Parameters - **appToken** (String) - Optional - An app token to access the PSU API. - **computerName** (String) - Optional - The HTTP address of the PSU REST API server. - **integrated** (SwitchParameter) - Optional - Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal. - **useDefaultCredentials** (SwitchParameter) - Optional - Use default credentials when connecting to the management API. - **credential** (PSCredential) - Optional - Credentials to login to the PowerShell Universal Management API. - **trustCertificate** (SwitchParameter) - Optional - Whether the cmdlet should ignore certificate issues. ### Request Example ```powershell $runId = "a1b2c3d4-e5f6-7890-1234-567890abcdef" Get-PSUJobParameter -RunId $runId ``` ### Response #### Success Response (200) - **parameters** (Object) - An object containing the job parameters. #### Response Example ```json { "parameters": { "param1": "value1", "param2": 123 } } ``` ``` -------------------------------- ### Create Project Directory and Initialize npm Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/custom-components/building-custom-components.md Use PowerShell to create a new directory for your component and then initialize a new npm project within it. ```powershell New-Item -Path .\MyComponent -ItemType Directory Set-Location .\MyComponent npm init -y ``` -------------------------------- ### Get Job Output using Job Object Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Get-PSUJobOutput.txt This example shows how to first retrieve a job object using Get-UAJob and then pass that object to Get-UAJobOutput to get its output. This is useful when you already have the job object or need to perform operations on the job before retrieving its output. ```powershell $Job = Get-UAJob -Id 12 Get-UAJobOutput -Job $Job ``` -------------------------------- ### Create a Responsive Grid with 3 Cards Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDGrid.txt This example shows how to create a responsive grid where cards display in a row on large screens but stack on smaller devices. Each card contains a button. ```powershell PS >New-UDGrid -Container -Children { New-UDGrid -Item -ExtraSmallSize 12 -LargeSize 4 -Children { New-UDCard -Title "Card 1" -Content { New-UDButton -Text "Button 1" } } New-UDGrid -Item -ExtraSmallSize 12 -LargeSize 4 -Children { New-UDCard -Title "Card 1" -Content { New-UDButton -Text "Button 2" } } New-UDGrid -Item -ExtraSmallSize 12 -LargeSize 4 -Children { New-UDCard -Title "Card 1" -Content { New-UDButton -Text "Button 3" } } } -Id "grid2" ``` -------------------------------- ### Data Grid with Pre-loaded Data from Cache Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDDataGrid.txt This example shows how to initialize a data grid with data stored in the cache. Ensure the data is correctly formatted as an array of hashtables. ```powershell $Cache:Data = @( @{ Name = 'Adam'; number = Get-Random } @{ Name = 'Tom'; number = Get-Random } @{ Name = 'Sarah'; number = Get-Random } ) New-UDDataGrid -LoadRows { ``` -------------------------------- ### Respond to Job Feedback Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Set-PSUJobFeedback.txt This example demonstrates how to retrieve job feedback using Get-UAJobFeedback and then respond to it using Set-UAJobFeedback. Ensure you have a job ID to start. ```powershell PS C:\> $Job = Get-UAJob -Id 2 PS C:\> $JobFeedback = Get-UAJobFeedback -Job $Job PS C:\> Set-UAJobFeedback -JobFeedback $JobFeedback -Response "Hello, world!" ``` -------------------------------- ### Run ELK Stack Setup Source: https://github.com/ironmansoftware/universal-docs/blob/v5/development/logging.md Use these commands to set up the ELK stack using the docker-elk repository. Ensure you have Docker and Docker Compose installed. ```bash docker-compose up setup ``` ```bash docker-compose up ``` -------------------------------- ### Retrieve Scripts by Identity Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Get-PSUScript.txt This example shows how to retrieve scripts associated with a specific identity, such as a user. First, get the identity object, then pass it to the Get-UAScript cmdlet. ```powershell $Identity = Get-UAIdentity -Name 'Adam' Get-UAScript -Identity $Identity ``` -------------------------------- ### Apply PSU Deployment using Cmdlet Source: https://github.com/ironmansoftware/universal-docs/blob/v5/config/deployments.md Apply a deployment to the cluster using the Select-PSUDeployment cmdlet. This example pins the deployment, making the admin console and Management API read-only, which is recommended for production environments. ```powershell Get-PSUDeployment -Name 'Production' -Version '1.0.1' -Pin | Select-PSUDeployment ``` -------------------------------- ### Create Basic Circular Progress Bar Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDProgress.txt A basic example of creating a circular progress bar with a specified size and ID. This can be used as a starting point for further customization. ```powershell New-UDProgress -Circular -Size large -Id 'progress4' ``` -------------------------------- ### Nested Data Grids with Detail Content Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/data-display/data-grid.md Demonstrates how to load nested data grids using the -LoadDetailContent parameter. This example displays virtual machines and, upon expansion, shows a data grid of their network cards. Dummy data functions are included for illustration. ```powershell function Get-VirtualMachine { 1..10 | ForEach-Object { [PSCustomObject]@{ Name = "VM-$_" OperatingSystem = @("Windows Server 2019", "Windows Server 2022", "Ubuntu 20.02") | Get-Random Memory = @(64, 128, 512, 1024) | Get-Random Cores = @(8, 16, 32) | Get-Random } } } function Get-NetworkCard { param($VirtualMachine) 1..4 | ForEach-Object { [PSCustomObject]@{ Name = "NIC-$_" Speed = @(64, 128, 512, 1024) | Get-Random } } } New-UDApp -Content { New-UDDataGrid -LoadRows { $VMs = Get-VirtualMachine $VMs| Out-UDDataGridData -Context $EventData -TotalRows $VMs.Length } -Columns @( New-UDDataGridColumn -Field Name New-UDDataGridColumn -Field OperatingSystem New-UDDataGridColumn -Field Memory -Render { New-UDTypography -Text "$($EventData.Memory) GB\s" } New-UDDataGridColumn -Field Cores ) -AutoHeight $true -LoadDetailContent { $VirutalMachine = $EventData.row New-UDDataGrid -LoadRows { $NICs = Get-NetworkCard -VirtualMachine $VirutalMachine $NICs | Out-UDDataGridData -Context $EventData -TotalRows $NICs.Length } -Columns @( New-UDDataGridColumn -Field Name New-UDDataGridColumn -Field Speed -Render { New-UDTypography -Text "$($EventData.Speed) GB\s" } ) -AutoHeight $true } } ``` -------------------------------- ### Limit Custom API Requests Source: https://github.com/ironmansoftware/universal-docs/blob/v5/api/rate-limiting.md Configure a rate limit for a specific custom API endpoint. This example limits the GET requests to '/api/users' to 100 per minute. ```powershell New-PSURateLimit -Endpoint "GET|/api/users" -TimeSpan "00:01:00" -Limit 100 ``` -------------------------------- ### Create a Basic Form Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDForm.txt This example demonstrates how to create a simple form with a textbox and display the entered value using a toast message upon submission. ```powershell New-UDForm -Id 'form1' -Content { New-UDTextbox -Id 'form1Textbox' -Label 'Name' } -OnSubmit { Show-UDToast -Message ($EventData.form1Textbox) } ``` -------------------------------- ### Update PSBlazor Components with PowerShell Variables Source: https://github.com/ironmansoftware/universal-docs/blob/v5/portal/portal-widgets/syntax.md Use the `$Variables` dictionary in PowerShell to set and get variables that can update PSBlazor components. This example shows updating a 'TestVariable' on button click. ```powershell $Variables["TestVariable"] = "Not Clicked" function OnClick { $Variables["TestVariable"] = "Clicked" } ``` -------------------------------- ### Grid using Rows and Columns Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDGrid.txt Demonstrates creating a grid layout using New-UDRow and New-UDColumn aliases. ```powershell New-UDRow -Columns { New-UDColumn -Size 4 -Content { New-UDCard -Title "Card 1" -Content {} } New-UDColumn -Size 4 -Content { New-UDCard -Title "Card 2" -Content {} } New-UDColumn -Size 4 -Content { New-UDCard -Title "Card 3" -Content {} } } -Id 'grid5' ``` -------------------------------- ### Stop a Terminal Instance Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Stop-PSUTerminalInstance.txt This example demonstrates how to retrieve a specific terminal instance by name, start it, and then subsequently stop it using Stop-PSUTerminalInstance. Ensure the terminal instance exists and is running before attempting to stop it. ```powershell $Terminal = Get-PSUTerminal | Where-Object Name -eq 'Terminal1' Start-PSUTerminalInstance -Terminal $Terminal Get-PSUTerminalInstance | Stop-PSUTerminalInstance ``` -------------------------------- ### Unblock PowerShell Universal Files Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/upgrading.md After extracting ZIP files, run this command recursively from an elevated PowerShell prompt to ensure all files can be executed. This is crucial for IIS ZIP installations to prevent the 'IIS App Pool Does Not Start' issue. ```powershell Get-ChildItem -Recurse | Unblock-File ``` -------------------------------- ### Grow Transition Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/utilities/transitions.md Use the grow transition to fade and grow a component into place. The `Set-UDElement` cmdlet manages the transition state. ```powershell New-UDTransition -Id 'test' -Content { New-UDCard -Text "Hey" } -In -Grow -Timeout 1000 New-UDSwitch -OnChange { Set-UDElement -Id 'test' -Properties @{ in = $EventData -eq 'True' } } -Checked $true ``` -------------------------------- ### Install PowerShell Universal Module Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/README.md Installs the Devolutions.PowerShellUniversal module from the PowerShell Gallery. This module is used to manage the Universal server installation. ```powershell Install-Module Devolutions.PowerShellUniversal ``` ```powershell Install-PSUServer -LatestVersion ``` -------------------------------- ### Create Basic Switches Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/inputs/switch.md Demonstrates how to create a basic switch and a disabled switch. ```powershell New-UDSwitch -Checked $true New-UDSwitch -Checked $true -Disabled ``` -------------------------------- ### Create a Basic Tooltip with New-UDTooltip Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDTooltip.txt This example demonstrates how to create a basic tooltip component. It requires TooltipContent and Content parameters. ```powershell New-UDTooltip -TooltipContent { New-UDTypography -Text "Hello World" } -Content { New-UDButton -Text "Hover over me" } -Id "tooltip1" ``` -------------------------------- ### Install Universal Module and Remove PSUServer Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/upgrading.md For upgrading from previous versions, first install the Universal module to version 4.4.0 and then remove the existing PSUServer installation. ```powershell Install-Module Universal -RequiredVersion 4.4.0 Remove-PSUServer ``` -------------------------------- ### Expansion Panel Group Examples Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDExpansionPanelGroup.txt Examples demonstrating the usage of New-UDExpansionPanelGroup for different scenarios. ```APIDOC ## Example 1: Basic Expansion Panel Group ### Description Creates a basic expansion panel group with three expansion panels. ### Code ```powershell New-UDExpansionPanelGroup -Id 'expandsionPanelGroup1' -Children { New-UDExpansionPanel -Title "Hello" -Content {} -Active -Id 'expansionPanel1' New-UDExpansionPanel -Title "Hello" -Content { New-UDElement -Tag 'div' -Content { "Hello" } } -Id 'expansionPanel2' New-UDExpansionPanel -Title "Hello" -Content { New-UDElement -Tag 'div' -id 'expEndpointDiv' -Content { "Hello" } } -Id 'expansionPanel3' } ``` ## Example 2: Accordion Style Expansion Panel Group ### Description Creates an accordion style expansion panel group. ### Code ```powershell New-UDExpansionPanelGroup -Id 'expandsionPanelGroup3' -Children { New-UDExpansionPanel -Title "Hello" -Content {} -Id 'expansionPanel6' New-UDExpansionPanel -Title "Hello" -Content {} -Id 'expansionPanel7' } -Type 'Accordion' ``` ## Example 3: Expansion Panel Group with Icons ### Description Creates an expansion panel group where each panel has an associated icon. ### Code ```powershell New-UDExpansionPanelGroup -Id 'expandsionPanelGroup4' -Children { New-UDExpansionPanel -Title "Hello" -Content {} -Icon (New-UDIcon -Icon 'Users') -Id 'expansionPanel8' New-UDExpansionPanel -Title "Hello" -Content {} -Icon (New-UDIcon -Icon 'User') -Id 'expansionPanel9' } ``` ``` -------------------------------- ### Create a Basic Grid with 3 Cards Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDGrid.txt This example demonstrates creating a basic grid layout with three cards arranged in a row. Each card contains a button. ```powershell PS >New-UDGrid -Container -Children { New-UDGrid -Item -ExtraSmallSize 4 -Children { New-UDCard -Title "Card 1" -Content { New-UDButton -Text "Button 1" } } New-UDGrid -Item -ExtraSmallSize 4 -Children { New-UDCard -Title "Card 1" -Content { New-UDButton -Text "Button 2" } } New-UDGrid -Item -ExtraSmallSize 4 -Children { New-UDCard -Title "Card 1" -Content { New-UDButton -Text "Button 3" } } } -Id "grid1" ``` -------------------------------- ### Install Performance Counters Script Source: https://github.com/ironmansoftware/universal-docs/blob/v5/platform/monitoring.md Run this PowerShell script from an elevated prompt to manually install performance counters if not using the MSI installer. This script creates a new performance counter category and its associated counters. ```powershell $categoryName = "PowerShell Universal" $categoryType = [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance $categoryExists = [System.Diagnostics.PerformanceCounterCategory]::Exists($categoryName) If (-Not $categoryExists) { $objCCDC = New-Object System.Diagnostics.CounterCreationDataCollection $objCCD1 = New-Object System.Diagnostics.CounterCreationData $objCCD1.CounterName = "Active Endpoints" $objCCD1.CounterType = "NumberOfItems32" $objCCD1.CounterHelp = "Active number of executing endpoints." $objCCDC.Add($objCCD1) | Out-Null $objCCD1 = New-Object System.Diagnostics.CounterCreationData $objCCD1.CounterName = "Execution Time" $objCCD1.CounterType = "averageTimer32" $objCCD1.CounterHelp = "Average execution time." $objCCDC.Add($objCCD1) | Out-Null $objCCD1 = New-Object System.Diagnostics.CounterCreationData $objCCD1.CounterName = "Execution Time Base" $objCCD1.CounterType = "averageBase" $objCCD1.CounterHelp = "Average execution time base." $objCCDC.Add($objCCD1) | Out-Null $objCCD1 = New-Object System.Diagnostics.CounterCreationData $objCCD1.CounterName = "Calls per second" $objCCD1.CounterType = "rateOfCountsPerSecond64" $objCCD1.CounterHelp = "Number of executions per second." $objCCDC.Add($objCCD1) | Out-Null $objCCD1 = New-Object System.Diagnostics.CounterCreationData $objCCD1.CounterName = "Active Connections" $objCCD1.CounterType = "numberOfItems64" $objCCD1.CounterHelp = "Number of active connections to dashboards" $objCCDC.Add($objCCD1) | Out-Null [System.Diagnostics.PerformanceCounterCategory]::Create($categoryName, $categoryHelp, $categoryType, $objCCDC)|Out-Null } ``` -------------------------------- ### Create Basic Timeline Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDTimeline.txt This example demonstrates how to create a basic timeline with several event items. Each item includes content and opposite content for display. ```powershell New-UDTimeline -Children { New-UDTimelineItem -Content { 'Breakfast' } -OppositeContent { '7:45 AM' } New-UDTimelineItem -Content { 'Welcome Message' } -OppositeContent { '9:00 AM' } New-UDTimelineItem -Content { 'State of the Shell' } -OppositeContent { '9:30 AM' } New-UDTimelineItem -Content { 'General Session' } -OppositeContent { '11:00 AM' } } -Id 'timeline1' ``` -------------------------------- ### Create a Basic Form with Input and Submit Button Source: https://github.com/ironmansoftware/universal-docs/blob/v5/portal/portal-widgets/forms.md Use PSBlazor syntax to create a form. Bind the form's Model to the PowerShell class instance and define an OnFinish callback for submission. Include FormItems for each input field and a submit button. ```markup
``` -------------------------------- ### Invoke-PSUEndpoint Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Invoke-PSUEndpoint.txt This example demonstrates how to invoke a specific API endpoint using the Invoke-PSUEndpoint cmdlet. ```APIDOC ## POST /myapi ### Description Returns an API endpoint internally. ### Method POST ### Endpoint /myapi ### Parameters #### Query Parameters - **ResponseVariable** (string) - Optional - {{ Fill ResponseVariable Description }} ### Request Example ```powershell Invoke-PSUEndpoint -URL '/myapi' ``` ### Response #### Success Response (200) - **System.Object** (object) - The output of the API call. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Create a Basic Gauge Component Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDGauge.txt This example demonstrates the creation of a basic gauge component with specified dimensions, value range, and styling. The -Style parameter accepts a hashtable for custom color. ```powershell New-UDGauge -Width 300 -Height 200 -Value 50 -ValueMinimum 0 -ValueMaximum 100 -StartAngle 0 -EndAngle 180 -CornerRadius "10px" -InnerRadius "50%" -OuterRadius "100%" -ArchCenterX "50%" -ArchCenterY "50%" -Style @{ color = "blue" } ``` -------------------------------- ### Collapse Transition Example Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/components/utilities/transitions.md Implement a collapse transition with a specified collapse height. The `Set-UDElement` cmdlet is used to toggle the collapsed state. ```powershell New-UDTransition -Id 'test' -Content { New-UDCard -Text "Hey" } -In -Collapse -CollapseHeight 100 -Timeout 1000 New-UDSwitch -OnChange { Set-UDElement -Id 'test' -Properties @{ in = $EventData -eq 'True' } } -Checked $true ``` -------------------------------- ### New-UDApp - Creating a Dashboard with Content Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDApp.txt This example demonstrates how to create a new dashboard with a single page using the -Content parameter. ```APIDOC ## New-UDApp - Creating a Dashboard with Content ### Description Creates a new dashboard with a single page defined by the -Content parameter. ### Method Cmdlet ### Endpoint N/A (PowerShell Cmdlet) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **Title** (String) - Optional - The title of the dashboard. - **Content** (Endpoint) - Required - The content for the dashboard, creating a single page. - **Theme** (Hashtable) - Optional - The theme for the dashboard. Use `New-UDTheme` to define a theme. - **Scripts** (String[]) - Optional - JavaScript files to run when the dashboard is loaded. - **Stylesheets** (String[]) - Optional - CSS files to run when the dashboard is loaded. - **Logo** (String) - Optional - A logo to display in the navigation bar. - **DefaultTheme** (String) - Optional - The default theme to show when the page is loaded. - **DisableThemeToggle** - Optional - Disables the toggle for the theme. - **HeaderPosition** (String) - Optional - The position of the header. - **HeaderColor** (DashboardColor) - Optional - The color of the header. - **HeaderBackgroundColor** (DashboardColor) - Optional - The background color of the header. - **NavigationLayout** (String) - Optional - The layout of the navigation. - **Navigation** (Hashtable[]) - Optional - Navigation items for the dashboard. - **HideUserName** - Optional - Hides the user name in the navigation. - **HideNavigation** - Optional - Hides the navigation. - **LoadNavigation** (Endpoint) - Optional - An endpoint to load navigation. - **HeaderContent** (Endpoint) - Optional - Content for the header. - **PageNotFound** (Endpoint) - Optional - An endpoint to display when a page is not found. - **NotAuthorized** (Endpoint) - Optional - An endpoint to display when a user is not authorized. - **SessionTimeoutModal** (ScriptBlock) - Optional - A script block for the session timeout modal. - **Menu** (Endpoint) - Optional - An endpoint for the menu. ### Request Example ```powershell New-UDApp -Title "Single Page App" -Content { New-UDText -Text "This is the main content of the dashboard." } ``` ### Response #### Success Response (200) Returns the created dashboard object. #### Response Example (Cmdlet output, typically not a JSON object for PowerShell cmdlets) ``` -------------------------------- ### Create a Basic Container with New-UDContainer Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDContainer.txt This example demonstrates how to create a basic container with a New-UDPaper component inside it. The container centers its content on larger screens. ```powershell New-UDContainer -Content { New-UDPaper -Content { } -Elevation 3 } ``` -------------------------------- ### Install PSScriptAnalyzer Module Source: https://github.com/ironmansoftware/universal-docs/blob/v5/platform/health-checks.md Install the PSScriptAnalyzer module from the PowerShell Gallery. This module is required by PowerShell Universal for certain features. ```powershell Install-Module PSScriptAnalyzer -Force ``` -------------------------------- ### Install Azure PowerShell Module Source: https://github.com/ironmansoftware/universal-docs/blob/v5/config/hosting/azure.md Installs the Azure PowerShell module, which is required for managing Azure resources via PowerShell. ```powershell Install-Module Az ``` -------------------------------- ### Create a Stepper with Multiple Steps Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDStep.txt This example demonstrates how to create a stepper component with three distinct steps. Each step has a label and an OnLoad script block that can render content and access previous step data via the $Body variable. It also includes an OnFinish script block to display a success message and the final stepper context. ```powershell New-UDStepper -Id 'stepper' -Steps { New-UDStep -OnLoad { New-UDElement -tag 'div' -Content { "Step 1" } New-UDTextbox -Id 'txtStep1' } -Label "Step 1" New-UDStep -OnLoad { New-UDElement -tag 'div' -Content { "Step 2" } New-UDElement -tag 'div' -Content { "Previous data: $Body" } New-UDTextbox -Id 'txtStep2' } -Label "Step 2" New-UDStep -OnLoad { New-UDElement -tag 'div' -Content { "Step 3" } New-UDElement -tag 'div' -Content { "Previous data: $Body" } New-UDTextbox -Id 'txtStep3' } -Label "Step 3" } -OnFinish { New-UDTypography -Text 'Nice! You did it!' -Variant h3 New-UDElement -Tag 'div' -Id 'result' -Content {$Body} } ``` -------------------------------- ### Install PowerShell Universal on Windows Source: https://github.com/ironmansoftware/universal-docs/blob/v5/get-started.md Installs the PowerShell Universal module and server as a service on Windows. Ensure PowerShell is run as administrator. ```powershell Install-Module Devolutions.PowerShellUniversal Install-PSUServer ``` -------------------------------- ### Start-UDDownload - Path Source: https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Start-UDDownload.txt Initiates a download of a file from a specified local path on the server. Ensure the path is accessible by the Universal Dashboard server. ```APIDOC ## Start-UDDownload -Path ### Description Starts the download of a file from a specified path within the dashboard. ### Method Start-UDDownload ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **FileName** (String) - Optional - The name of the file. Defaults to 'text.txt'. - **Path** (String) - Required - The local path to the file to be downloaded. - **ContentType** (String) - Optional - The content type of the file. Defaults to 'text/plain'. ### Request Example ```powershell Start-UDDownload -FileName 'report.pdf' -Path 'C:\path\to\your\report.pdf' -ContentType 'application/pdf' ``` ### Response #### Success Response (200) This cmdlet does not return a value. It initiates a file download. #### Response Example None ``` -------------------------------- ### Verify Docker Installation Source: https://github.com/ironmansoftware/universal-docs/blob/v5/getting-started/docker.md Run this command to confirm Docker is installed and check its version. This is a fundamental step before using any Docker commands. ```bash docker version ``` -------------------------------- ### Initiate Browser Downloads with PowerShell Source: https://github.com/ironmansoftware/universal-docs/blob/v5/apps/interaction.md Start a file download in the user's browser using Start-UDDownload. User interaction is required to permit the download. Not recommended for large files. ```powershell New-UDButton -Text 'Download' -OnClick { Start-UDDownload -StringData 'Hello, World!' } ``` -------------------------------- ### Install Universal PowerShell Module Source: https://github.com/ironmansoftware/universal-docs/blob/v5/config/management-api.md Installs the Universal PowerShell module from the PowerShell Gallery. This module simplifies interactions with the Management API. ```powershell Install-Module Universal ```