Invoke-UAScript not working on UA versions beyond 1.1.1?

Is anyone else experiencing this? The line being referenced in the error below happens to be where I call Invoke-UAScript.

> Object reference not set to an instance of an object. at <ScriptBlock>, <No file>: line 11

Pretty sure I am using the right approach:

$script = Get-UAScript -Name 'AdServerComputers.ps1'
Invoke-UAScript -Script $script

The above snippet of code is working as is on version 1.1.1

This doesn’t work on 1.3.1? I know I saw this problem with some version but I thought we had resolved it.

I will give it another run through this morning but I was not having success with it while testing yesterday. Unless it’s just a me problem :smiley:

Just tested again - no dice

Bummer. Ok. I’ll log an issue in our backlog and go from there. I’ll take a peek at the code to see if I can figure out a work around.

As always, many thanks!

Hey @RomPhreak, just to confirm - can you double check what version you are on?

You mention 1.1.1 - we did RECENTLY fix an invoke issue that is resolved in 1.3.1 - just retested it myself on a fresh install :slightly_smiling_face:

Could you also confirm the exact version in your UniversalAutomation.psd1 file?

image

Hey @leeberg - I sure can!

I have all releases from 1.0.0 - 1.3.1 installed but am using ‘-RequiredVersion 1.3.1’ when calling Import-Module.

“C:\Program Files\WindowsPowerShell\Modules\UniversalAutomation\1.3.1\UniversalAutomation.psd1”

#
# Module manifest for module 'UniversalAutomation'
#
# Generated by: Adam Driscoll
#
# Generated on: 4/17/2020
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'UniversalAutomation.psm1'

# Version number of this module.
ModuleVersion = '1.3.1'

If I misunderstood anything or didn’t provide the info you are requesting, just holler!

Strange! Alright, let’s try a few things:

  • Can you please verify which of the two commands is failing? (the Get or the Invoke)
  • is $script resolving at all? Is it returning null?
  • Does the Get-UAScript work for any other scripts? Is it just failing to get that particular script?
  • Likewise, can you invoke OTHER scripts?
  • Can you try specifying the -Id Parameter instead of Name for the Get and the invoke? I am not saying this is a workaround but it would be helpful for debugging!

I should elaborate a little more. Running Invoke-UAScript from the terminal, with any of the params, is failing for me regardless of the UA version I import (error below). However, if I create a UA script that calls Invoke-UAScript, that will indeed work on version 1.1.1. On version 1.3.1, the same script results in the error included in my first post.

Invoke-UAScript : Object reference not set to an instance of an object.
At line:1 char:1
+ Invoke-UAScript -Id 8
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-UAScript], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,UniversalAutomation.InvokeScriptCommand
  1. The Invoke
  2. $script returns a UniversalAutomation.Script type object
  3. No issues with Get-UAScript across the board
  4. Last two bullets answered in beginning of post

Thanks. We are looking into it

Thank you guys! If I can help further in any way, please let me know.

1 Like

Hey guys. Just wanted to let you know I tried everything on a brand new 2019 server while running UA via IIS. I encountered the same results regarding 1.1.1 vs 1.3.1 (only two I tried).

Howdy gents! Not meaning to pester, just wondering if you found anything more on this topic.

Sorry for not following up. This should be fixed in PSU 1.1.1 (UA is now included in PSU). PSU uses the same UA database so you should be able to uninstall UA and install PSU and it will pick up the DB.

The cmdlets are published here: https://www.powershellgallery.com/packages/Universal/1.0.2

The module doesn’t contain the entire Universal server.