Hi,
I am getting an error when the octopus tentacle is executing a Deploy.ps1 script. The Deploy script call a number of custom methods in a custom powershell module.
I can execute the script via powershell running as admin on the server where the tentacle is installed and the script executes fine.
I have tried the following each time the scripts errors.
Running the tentacle interactively as my domain account (I am a domain admin and an admin on the server).
Running the tentacle as the default LocalSystem account (default).
Running the tentacle as a service account with local admin and domain admin privileges.
See below error.
ERROR: Test-Account : Exception calling “FindByIdentity” with “3” argument(s): “Could
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: not load file or assembly ‘Microsoft.PowerShell.Commands.Management’ or one of
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: its dependencies. The system cannot find the file specified.”
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: At C:\Octopus\Applications\Dev\AMS.Core.Host\1.0.48_8\Deploy.ps1:16 char:1
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: + Test-Account -Account $ServiceAccount -Password $ServiceAccountPassword
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: + CategoryInfo : NotSpecified: ([Test-Account], MethodInvocati
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: onException
2013-12-11 00:11:33 INFO [Deploy Script] ERROR: + FullyQualifiedErrorId : FileNotFoundException,Test-Account
2013-12-11 00:11:33 INFO [Deploy Script] ERROR:
Here is the method that is being called.
@@@
Function Test-Account() {
Param (
[Parameter(Mandatory=$true)] [String] $Account,
[Parameter(Mandatory=$true)] [String] $Password
)
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$domainContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Domain)
$foundUser = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($domainContext, [System.DirectoryServices.AccountManagement.IdentityType]::SamAccountName, $Account)
if ($foundUser -eq $Null) {
Write-Error "User $Account not exist in AD"
}
$contextType = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$principalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($contextType)
if (!$principalContext.ValidateCredentials($Account, $Password))
{
Write-Error "Service Account Password is invalid for $Account"
}
}
@@@
This is the line of script that is throwing the error.
@@@
$foundUser = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($domainContext, [System.DirectoryServices.AccountManagement.IdentityType]::SamAccountName, $Account)’
@@@
Environment information
Server: Windows Server 2008 R2.
I have tried this with PS v3 and PS v4.
$psversiontable output
Name Value
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.18052
BuildVersion 6.3.9600.16406
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
Cheers
Adam