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!

    $PSCredential- round two

    Scheduled Pinned Locked Moved Support
    27 Posts 3 Posters 54 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.
    • rhessingerR Offline
      rhessinger inedo-engineer
      last edited by

      Hi @Jonathan-Engstrom ,

      I have noticed the $ServerName uses the name of my server configured in Otter, not the actual computer name. Have you tried running the remediation using $env.computername instead of $ServerName? Or can you verify the Server Name in Otter matches the computers name?

      Thanks,
      Rich

      Products Engineer, Inedo

      1 Reply Last reply Reply Quote 0
      • Jonathan.EngstromJ Offline
        Jonathan.Engstrom
        last edited by

        That's a good idea, but I actually started off using the $env:computername and switched to $servername thinking that maybe somehow Otter wasn't using the $env:computername variable, but it didn't make any difference.

        1 Reply Last reply Reply Quote 0
        • rhessingerR Offline
          rhessinger inedo-engineer
          last edited by

          Hi @Jonathan-Engstrom ,

          What version of PowerShell do you have installed on your SQL server? I'm running 5.1.18362.628.

          Thanks,
          Rich

          Products Engineer, Inedo

          1 Reply Last reply Reply Quote 0
          • Jonathan.EngstromJ Offline
            Jonathan.Engstrom
            last edited by

            It's a 2016 Server, so it comes preinstalled with 5.1. 5.1.14393.3471 is the specific version.

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

              @Jonathan-Engstrom said in $PSCredential- round two:

              Same code, same machine.

              Same user?

              @Jonathan-Engstrom said in $PSCredential- round two:

              it would help to understand why.

              FYI -- Otter doesn't format PowerShell; it parses the PowerShell script (using MIcrosoft's parser), looks for variable tokens, and "injects" a variable into the runtime if there's a matching variable.

              The interactive Powershell Host (which you're using, ps.exe) also does things differently. There's a ton of layers-upon-layers with active directory. so it'll take some trial/error to find out what's happening.

              1 Reply Last reply Reply Quote 0
              • Jonathan.EngstromJ Offline
                Jonathan.Engstrom
                last edited by

                Yes, same user. Like I said, I have taken great care to eliminate variables trying to understand what is going on.

                1 Reply Last reply Reply Quote 0
                • rhessingerR Offline
                  rhessinger inedo-engineer
                  last edited by

                  Hi @Jonathan-Engstrom ,

                  Have you tried wrapping your PSEnsure inside of a with block to force everything to run as a specific Resource Credential?

                  Example using a resource credential named AdAdminResourceCredentials:

                  with credentials = AdAdminResourceCredentials
                  {
                  	PSEnsure
                  	(
                  	    Key: RSHStuff,
                  	    Value: True,
                  	    Collect: >>
                  
                  	        $ErrorActionPreference = 'SilentlyContinue'
                  	        $TargetOU = 'Users'
                  	        $Value = (Get-ADComputer -Identity $env:COMPUTERNAME).DistinguishedName -match $TargetOU
                  	        $CurrentValue = (Get-ADComputer -Identity $env:COMPUTERNAME).DistinguishedName
                  	        ((($Value -eq $true) -and (($env:COMPUTERNAME) -match 'MyComputerName')) -or ($env:COMPUTERNAME -notmatch 'MyComputerName')) 
                  	        >>,
                  	    Configure: >>
                  	                
                  	        $samAccountName = $ServerName
                  	        $newOU = [adsi]"LDAP://$TargetOU"
                  	        $comp= ([adsisearcher]"samaccountname=$($ServerName)$").FindOne()
                  	        Write-Host $comp.GetDirectoryEntry()
                  	                                
                  	                                >>,
                  	    Debug: true,
                  	    Verbose: true
                  	);
                  }
                  

                  Please note that my PowerShell in collect and configure is not 1 to 1 with yours, I would replace my PowerShell script with yours in those two properties.

                  I also was talking with one of the solutions architects on a similar Otter execution question. He suggested that sometimes it is easier to figure out PowerShell issues by running PSExec under the local system account and attempting to run your PowerShell commands that way. It will sometimes show you more detailed errors than Otter. I would try running PSExec -s powershell, which will open up a PowerShell console as the local system account, and then typing in the lines of PowerShell you have had trouble with.

                  Thanks,
                  Rich

                  Products Engineer, Inedo

                  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
                  • 2
                  • 2 / 2
                  • First post
                    Last post
                  Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation