Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue found in AutomatePS on Automate 2022 (running using Windows 2022) #30

Closed
sknijn opened this issue Jan 13, 2023 · 13 comments · Fixed by #31
Closed

Compatibility issue found in AutomatePS on Automate 2022 (running using Windows 2022) #30

sknijn opened this issue Jan 13, 2023 · 13 comments · Fixed by #31

Comments

@sknijn
Copy link

sknijn commented Jan 13, 2023

Expected Behavior

Start workflow "MailTriggerMonitor"

Actual Behavior

When running the script from powershell.exe , I got this error:

MethodException: C:\Program Files\WindowsPowerShell\Modules\AutoMatePS\5.1.1\Functions\Public\Invoke-AMRestMethod.ps1:51
Line |
51 | [ArgumentCompleter([AMConnectionCompleter])]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Multiple ambiguous overloads found for ".ctor" and the argument count: "1".

When running the script from Powershell ISE, it almost works except for this issue:
Start-AMWorkflow : Unsupported input type '3' encountered!
At C:\Users\KnijnS\Desktop\Untitled1.ps1:13 char:13

  • $Workflow | Start-AMWorkflow
  •         ~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (@{ID={66506296-...SIAV26787:9708}:PSObject) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-AMWorkflow

Steps to Reproduce the Problem

  1. Setup Windows 2022 server with Automate 2022. Create a script Untitled1.ps1 with content:
    Disconnect-AMServer
    $AutomateServer = ($env:computername).ToUpper()
    $AutomatePort = "9708"
    $ConnectionStoreFilePath = "C:\SecurePasswords$($ENV:Username)_Automate_passwords.xml"
    If (!(Test-Path -Path $ConnectionStoreFilePath)) {
    New-AMConnectionStoreItem -FilePath $ConnectionStoreFilePath -Server $AutomateServer -Port $AutomatePort -Credential (Get-Credential)
    }
    Connect-AMServer $AutomateServer -ConnectionStoreFilePath $ConnectionStoreFilePath -Port $AutomatePort | Out-Null
    $Workflow = Get-AMWorkflow -Name MailTriggerMonitor
    $Workflow | Start-AMWorkflow

Specifications

  • AutomatePS Version: 5.1.1
  • PowerShell Version: 7.3.0 or 5.1.20348.1366
  • Automate Version: 2022
@davidseibel
Copy link
Collaborator

The API has a major issue in the 2022 beta. It seems to be an issue with the JSON serialization not adding the __type property to objects returned by the API. This is needed by AutomatePS to correctly POST back to the API (this property is then used by the API to determine which class to cast into during deserialization). I opened a case with Fortra, and they are aware. Hopefully it's fixed in the GA release.

@sknijn
Copy link
Author

sknijn commented Jan 13, 2023

Hi David.

I believe Automate 2022 went GA of Dec 22, 2022 (https://community.fortra.com/support/current-product-versions/)
I was able to start a message flow using AutomatePS and Powershell ISE.
I did have to change something to get rid of this error: Start-AMWorkflow : Unsupported input type '3' encountered!

Start-AMWorkflow.ps1
if ($obj.Type -eq "Workflow") {
changed it to
if ($obj.Type -eq 3) {

Maybe its worth to look into their latest release?

Regards,
Sander

@sknijn
Copy link
Author

sknijn commented Jan 16, 2023

Hi David,

I changed in my script the
"import-module AutomatePs"
into
"using module AutomatePS"
after that no more errors about ambiguous overloads found.
See more info: vNugglets/vNuggletsPSMod_vDNetworking#1

Also for backwards compatibility, I modified this in your module:
if ($obj.Type -eq "Workflow") {
==>
if ($obj.Type -eq "Workflow" -or $obj.Type -eq 3) {

Tomorrow I will be testing other cmdlets we are using from your package in combination with Automate 2022 and Windows 2022.

@sknijn
Copy link
Author

sknijn commented Jan 26, 2023

Hi David,

Any idea's when an updated version of your module is ready?

Regards,
Sander

@davidseibel
Copy link
Collaborator

I haven't had time to upgrade yet, it will probably be a couple months. I didn't realize 2022 was already released, hopefully they addressed the API issue I brought up in the beta.

@sknijn
Copy link
Author

sknijn commented Jun 2, 2023

Hi David,

Any update yet?

Regards,
Sander

@davidseibel
Copy link
Collaborator

I dug into this more today, and I was apparently mistaken when I thought this was an API issue. I have added the necessary changes for 2022 support but have not fully tested it. If you'd like you can grab a copy from my fork and test. Please test with caution.

@sknijn
Copy link
Author

sknijn commented Jun 5, 2023

Hi David. Thank you for looking into this.
I tested your fork, unfortunately some parts still don't work correctly.
I got these errors:

PS C:> $Workflow = Get-AMWorkflow 'Macro-Signing_Automation'
The property 'Name' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\AutomatePS\Types\Automate.classes.v11.ps1:88 char:9

  •     $this | Add-Member -MemberType NoteProperty -Name "LockedByUs ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
    • FullyQualifiedErrorId : PropertyNotFoundStrict

PS C:> $Workflow = Get-AMWorkflow -ID '54d0ba94-3e6c-43ca-acd9-94dc7fbb3efc'
failure : Unexpected error
At C:\Program Files\WindowsPowerShell\Modules\AutomatePS\Functions\Public\Invoke-AMRestMethod.ps1:103 char:13

  •         throw "$($tempResult.Result) : $($tempResult.Info)"
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (failure : Unexpected error:String) [], RuntimeException
    • FullyQualifiedErrorId : failure : Unexpected error

@davidseibel
Copy link
Collaborator

I'm not able to recreate the first error. The second one I'm almost certain isn't AutomatePS related, to me that looks like an invalid workflow ID passed to the API. Usually, the workflow ID's are surrounded by curly braces, can you retry with:

$workflow = Get-AMWorkflow -ID '{54d0ba94-3e6c-43ca-acd9-94dc7fbb3efc}'

What is the version of Automate/PowerShell you're running? Also, are you sure you're only loading the new version of the module in your PowerShell session?

@sknijn
Copy link
Author

sknijn commented Jun 6, 2023

Hi David,

I was using Set-StrictMode -Version 2.0 in my Powershell and then I got the first error.
Without StrictMode it works fine.

I added the curly brackets and also that seems to work now.

I will continue and test some more...

@sknijn
Copy link
Author

sknijn commented Jun 7, 2023

All works fine now! Thank you for this update David.
Will you also update AutomatePS.Health ? We are using that module too...

Regards,
Sander

@davidseibel
Copy link
Collaborator

I don't think any changes are needed for the AutomatePS.Health module. If you do run into problems, please open an issue against the AutomatePS.Health repo.

Thanks

@sknijn
Copy link
Author

sknijn commented Jun 8, 2023

Works as a charm, David.
Thank you very much!

You may close this Issue and merge Fork to main branch

Regards,
Sander

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants