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