Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Error when checking for Az powershell module



  • Hi,

    I'm trying to make sure the Azure powershell module is installed on certain server roles.

    In the desired configuration OtterScript I have:

    Ensure-PsModule
    (
        Module: Az,
        Exists: true,
        Repository: PSGallery
    );
    

    This correctly detects the server as drifted:
    175c5859-423e-44c4-993b-cf36b0709256-image.png

    When I then try to remediate the drift I get an error:
    9d28eb6e-27a9-4777-af22-d82d8e6f9698-image.png

    I'm not very experienced in remediating drift with otter in this way yet, so I might be missing something obvious?

    Thanks,
    Justin


  • inedo-engineer

    Hi @Justinvolved ,

    That looks like an error coming from PowerShell; you can see what Powershell commands are being emitted executed, so I'm guessing it's some kind of issue with the source?

    I'd try to start there, and see if you figure out the underlyinig Powershell error. Here is the code that's generating the scrpt

    https://github.com/Inedo/inedox-scripting/blob/master/Scripting/InedoExtension/Configurations/PsModule/PsModuleConfiguration.cs#L224

    Cheers,
    Alana



  • Hey Alana,

    Turns out the error is already in the Collection step. When I set the variable to use PowerShell core the error is not there:
    7da50bba-13b7-456a-900a-38eab20759ab-image.png

    I do have powershell 5.1 installed on the server, and when I run a Get-Module -ListAvailable I get a valid result (this is the part where the Collect step errors...) When I run Get-Module -ListAvailable with a Module name that is not installed yet I get an empty line. Is the code somehow choking on the empty line? because it seems "Expected to start with a valid JSON token" does not expect an empty string..

    Thanks,

    Justin


  • inedo-engineer

    Hi @Justinvolved,

    Would you be able to send us the output of Get-Module -ListAvailable on PowerShell 5.1? I would like to take a look and see if there is anything causing a parsing error in Otter. If it is not safe to post here, you can email it to support@inedo.com and prefix the subject with [QA-1405] and then comment back here when you have sent it.

    Thanks,
    Rich


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation