azureautomation / azure-automation-ise-addon

The Azure Automation PowerShell ISE Add-On makes it easy to author and test your runbooks in your local PowerShell ISE
https://www.powershellgallery.com/packages/AzureAutomationAuthoringToolkit/
Other
122 stars 24 forks source link

Error updating automation variable #117

Open TotallyInformation opened 8 years ago

TotallyInformation commented 8 years ago

v0.2.3.4

After updating to this version today, I get the following error from a previously working script:

PS C:\...\ICT-MAIN-AUTOMATION> Get-AutomationVariable -Name 'AAD-GetAllUsers-tempCount'
0

PS C:\...\ICT-MAIN-AUTOMATION> set-AutomationVariable -Name 'AAD-GetAllUsers-tempCount' -Value 5
Variable 'AAD-GetAllUsers-tempCount' not found for account 'AuthoringToolkit'
At C:\Users\julia\Documents\WindowsPowerShell\Modules\AzureAutomationAuthoringToolkit\0.2.3.4\AzureAutomationAuthoringToolkit
Inner.psm1:485 char:9
+         throw "Variable '$Name' not found for account 'AuthoringToolk ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Variable 'AAD-G...thoringToolkit':String) [], RuntimeException
    + FullyQualifiedErrorId : Variable 'AAD-GetAllUsers-tempCount' not found for account 'AuthoringToolkit'

Clearly the variable exists and is accessible locally.

jodoglevy commented 8 years ago

My guess would be that this is a bug related to 0 being a falsey value, and the ISE add on interpreting it as null. If you use the ISE add on UI to set the value of the variable to some number greater than 0, does set-automationvariable work? On Jul 4, 2016 9:07 AM, "Julian Knight" notifications@github.com wrote:

v0.2.3.4

After updating to this version today, I get the following error from a previously working script:

PS C:...\ICT-MAIN-AUTOMATION> Get-AutomationVariable -Name 'AAD-GetAllUsers-tempCount' 0

PS C:...\ICT-MAIN-AUTOMATION> set-AutomationVariable -Name 'AAD-GetAllUsers-tempCount' -Value 5 Variable 'AAD-GetAllUsers-tempCount' not found for account 'AuthoringToolkit' At C:\Users\julia\Documents\WindowsPowerShell\Modules\AzureAutomationAuthoringToolkit\0.2.3.4\AzureAutomationAuthoringToolkit Inner.psm1:485 char:9

  • throw "Variable '$Name' not found for account 'AuthoringToolk ...
  • 
    - CategoryInfo          : OperationStopped: (Variable 'AAD-G...thoringToolkit':String) [], RuntimeException
    - FullyQualifiedErrorId : Variable 'AAD-GetAllUsers-tempCount' not found for account 'AuthoringToolkit'

Clearly the variable exists and is accessible locally.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/azureautomation/azure-automation-ise-addon/issues/117, or mute the thread https://github.com/notifications/unsubscribe/AAOUXWTp7CoommnpeBdiqZh_ZxGHCwcKks5qSQWCgaJpZM4JEWtX .

TotallyInformation commented 8 years ago

Hi, sorry, I've not had time to test this yet. I will do when I get back from family holidays.

mdowst commented 6 years ago

I have confirmed this is still an issue, and yes it appears to be related to the fact that the value is null. On the Set-AutomationVariable function in the file AzureAutomationAuthoringToolkitInner.psm1. It is checking for a value, and if not found it throws this error instead of trying to set the value.

Also, I found that the Set-Content lines in this function are failing as well because the depth parameter is set to 999 on the ConvertTo-Json command. The max value allowed for this command is 100. Please let me know if I should report this as a separate issue.