ironmansoftware / universal-automation

Universal Automation is the PowerShell-first automation platform.
https://ironmansoftware.com/universal-automation/
MIT License
24 stars 4 forks source link

Sample script uses $PSScriptRoot, doesn't work interactively #7

Closed Windos closed 4 years ago

Windos commented 4 years ago

Describe the Issue

When running the sample script interactively, the use of $PSScriptRoot results in errors if your working directory isn't the expected directory.

To Reproduce

  1. Open PowerShell Console
  2. Paste Sample Script
  3. Notice errors as it executes

Expected behavior

Dynamically locate the module and reference the example script accordingly.

Screenshots

image

Script Sample

Offending line is number 69:

$Script = New-UAScript -Name "New User Onboarding Request" -ManualTime 28000 -ScriptBlock ([scriptblock]::Create((Get-Content "$PSScriptRoot\UniversalAutomation.Dashboard\examplescripts\onboarding.ps1"))) -Status "Draft"

Suggest change to:

$Script = New-UAScript -Name "New User Onboarding Request" -ManualTime 28000 -ScriptBlock ([scriptblock]::Create((Get-Content "$((Get-Module UniversalAutomation.Dashboard -ListAvailable).ModuleBase)\examplescripts\onboarding.ps1"))) -Status "Draft"

Version Information

adamdriscoll commented 4 years ago

This shouldn't have been included with the sample script. It was part of one of our demo scripts and not a function of UA. I've fixed the sample script.