Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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)

    Scheduled Pinned Locked Moved Support
    4 Posts 3 Posters 10 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      philippe.camelio_3885
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer
        last edited by

        @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.

        apxltdA 1 Reply Last reply Reply Quote 0
        • apxltdA Offline
          apxltd inedo-engineer @atripp
          last edited by

          @atripp @philippe-camelio_3885 whoops!

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

          Founder and CEO, Inedo

          P 1 Reply Last reply Reply Quote 0
          • P Offline
            philippe.camelio_3885 @apxltd
            last edited by

            @apxltd
            Thank you, problem fixed 👏

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation