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!

OTTER 3 - Help needed on PSEnsure (works on Plan but not on Configuration)



  • Hello
    I made a small PSEnsure script to create an AD Group - test case -
    Running directly from an Otter Plan it is working as expected:

    • if the group exists, it does nothing
    • if the group doesn't exist, it creates the group

    From a configuration Plan inside a Role

    • the Verify step works as expected
      0a4c3f93-5e71-4eff-a481-395d9031d216-image.png
    • the Remediation step returns an error
      8b5dd571-23c3-42b8-a1ca-aff4a3049864-image.png

    Powershell Script: New-ADGroup

    <# 
    .DESCRIPTION
    Create AD Group 
    
    .AHCONFIGKEY
    $Name
    
    .AHEXECMODE
    $ExecMode
    #>
    Param(
       [Parameter(Mandatory=$false)]
       [string]$Name="TEST", 
    
       [Parameter(Mandatory=$false)]
       [string]$GroupCategory="Security", 
    
       [Parameter(Mandatory=$false)]
       [string]$GroupScope="DomainLocal", 
    
       [Parameter(Mandatory=$false)]
       [string]$DisplayName="TEST", 
    
       [Parameter(Mandatory=$false)]
       [string]$Path="OU=Serveurs,OU=Groupes,DC=OCAPIAT,DC=FR",
    
       [Parameter(Mandatory=$false)]
       [string]$Description="Test"
    )
        if ($ExecMode -eq "Configure") {
            if ([bool](Get-ADGroup -filter "Name -eq '$($Name)'")){ return $true} else { 
                New-ADGroup -Name $Name -GroupCategory $GroupCategory -GroupScope $GroupScope  -DisplayName $DisplayName -Path $Path -Description $Description -Verbose
            }
     
    }else{
        if ([bool](Get-ADGroup -filter "Name -eq '$($Name)'")){ return $true} else { return $false }
    }
    

    Otter Plan : TESTPLAN

    ##AH:UseTextMode
    PSEnsure New-ADGroup
    (
        Name: TEST2
    );
    

    Role : TESTROLE

    ##AH:UseTextMode
    
    
    PSEnsure New-ADGroup
    (
        Name: TEST2
    );
    

    6f1f3b54-8772-423b-ad9e-76164ae0a111-image.png

    Prerequisite on the server : RSAT-AD-Powershell feature

    I can't figure out what I am doing wrong, any help would be appreciate

    Best Regards
    Philippe


  • inedo-engineer

    @philippe-camelio_3885 thanks for sharing all the logs!

    Can you confirm... which version of the Scripting extension are you using? I see @apxltd made a pre-release version (1.10.2-rc.3) but it's not yet released.


  • inedo-engineer

    @atripp @philippe-camelio_3885 whoops!

    This error should be fixed already, and I just published 1.10.2 - please try that!



  • @apxltd
    Thank you, problem fixed 👏


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation