Author Posts

August 17, 2018 at 9:33 am

I am trying to run the deployment using powershell dsc from Bamboo.

As part of this process i am trying to pass the username and password as bamboo variable inside script but whenever script gets executed it throws the below error.

I am using the push mode method in powershell dsc

New-CimSession : The user name or password is incorrect.

17-Aug-2018 03:53:33
At D:\ProgramFiles\bamboo-agent-home\xml-data\build-dir\223313931-223379483\DEV\DeployScript\WorkflowDSC.ps1:105

17-Aug-2018 03:53:33
char:12

17-Aug-2018 03:53:33
+ $Session = New-CimSession -ComputerName "usadc-vsqqtcs02.quintiles.ne ...

17-Aug-2018 03:53:33
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

17-Aug-2018 03:53:33
    + CategoryInfo          : AuthenticationError: (:) [New-CimSession], CimException

17-Aug-2018 03:53:33
    + FullyQualifiedErrorId : HRESULT 0x8007052e,Microsoft.Management.Infrastructure.CimCmdlets.NewCimSessionCommand

17-Aug-2018 03:53:33
    + PSComputerName        : usadc-vsqqtcs02.quintiles.net

17-Aug-2018 03:53:33

17-Aug-2018 03:53:33
Start-DscConfiguration : Cannot bind argument to parameter 'CimSession' because it is null.

17-Aug-2018 03:53:33
At D:\ProgramFiles\bamboo-agent-home\xml-data\build-dir\223313931-223379483\DEV\DeployScript\WorkflowDSC.ps1:106

17-Aug-2018 03:53:33
char:60

17-Aug-2018 03:53:33
+ ... DscConfiguration -Path .\WorkFlowWebsite -CimSession $Session -Verbos ...

17-Aug-2018 03:53:33
+                                                          ~~~~~~~~

17-Aug-2018 03:53:33
    + CategoryInfo          : InvalidData: (:) [Start-DscConfiguration], ParameterBindingValidationException

17-Aug-2018 03:53:33
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.DesiredStateConfigur

17-Aug-2018 03:53:33
   ation.Commands.StartDscConfigurationCommand

17-Aug-2018 03:53:33

17-Aug-2018 03:53:33

August 17, 2018 at 1:56 pm

You have to help us by posting your script here, or at least a similar code using the code posting tags.

August 19, 2018 at 8:34 pm

I suspect this has a lot more to do with Bamboo, which I'm not familiar with, than with DSC itself. DSC also has very specific requirements for credentials, since it requires encryption in the final MOF.

August 20, 2018 at 3:19 pm

Below is my DSC script

 

configuration WorkFlowWebsite

{

Import-DscResource -ModuleName PSDesiredStateConfiguration

Import-DscResource -ModuleName xWebAdministration

 

Node $AllNodes.NodeName

{

#Install the IIS Role

WindowsFeature IIS

{

Ensure = "Present"

Name = "Web-Server"

}

# Create a Web Application Pool

xWebAppPool NewWebAppPool

{

Name   = $Node.WebAppPoolName

Ensure = "Present"

State  = "Started"

IdentityType = "SpecificUser"

Credential  = $cred

}

#Create physical path website

File NewWebsitePath

{

DestinationPath = $Node.PhysicalPathWebSite

Type = "Directory"

Ensure = "Present"

}

#Create a New Website with Port

xWebSite NewWebSite

{

Name   = $Node.WebSiteName

Ensure = "Present"

ApplicationPool = $Node.WebAppPoolName

BindingInfo = MSFT_xWebBindingInformation

{

Protocol = "http"

Port = $Node.Port

}

 

PhysicalPath = $Node.PhysicalPathWebSite

State = "Started"

DependsOn = @("[xWebAppPool]NewWebAppPool","[File]NewWebsitePath")

}

File Buildbackup

{

Ensure = "Present"  # You can also set Ensure to "Absent"

Type = "Directory" # Default is "File".

Recurse = $true # Ensure presence of subdirectories, too

MatchSource = $true

SourcePath = "D:\tcwaworkflow"

DestinationPath = "D:\tcwaworkflowbackup\$(get-date -f MM-dd-yyyy-HH-MM-ss)"

}

File RemoveDiretory

{

Type = "Directory"

DestinationPath = "D:\tcwaworkflow\"

Force = $true

Ensure = "Absent"

Recurse = $true

}# end File

File Filecreate

{

Type = 'Directory'

DestinationPath = "D:\tcwaworkflow"

Ensure = "Present"

}

 

Archive ExtractPackage

{

Ensure = "Present"  # You can also set Ensure to "Absent"

Path = "C:\ftpupload\Workflow_Staging\Build\WorkFlowAPIdev.zip"

Destination = "D:\tcwaworkflow"

DependsOn = "[File]Buildbackup"

}

ServiceSet StartIIS

{

Name        = "W3SVC"

StartupType = "Manual"

State       = "Running"

}

 

}

}

#You can place the below in another file to create multiple websites using the same configuration block.

$Config = @{

AllNodes = @(

@{

NodeName = "usadc-vsqqtcs02.quintiles.net";

WebAppPoolName = "tcwaworkflow";

WebSiteName = "tcwaworkflow";

PhysicalPathWebSite = "D:\tcwaworkflow";

Port = 7702

PSDscAllowPlainTextPassword = $true

PSDscAllowDomainUser = $true

}

)

}

WorkFlowWebsite -ConfigurationData $config

$username = 'QAMR-ACCOUNTS\${bamboo.yaccount}'

$password = '${bamboo.ypassword}'

write-host "$username"

write-host "$password"

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force

$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword

$Session = New-CimSession -ComputerName "usadc-vsqqtcs02.quintiles.net" -Credential $credential

Start-DscConfiguration -Path .\WorkFlowWebsite -CimSession $Session -Verbose -Wait -Force

August 20, 2018 at 4:42 pm

Usage of variables in single quotes are problem here. Variable expansion works only with double quotes.

#replace
$username = 'QAMR-ACCOUNTS\${bamboo.yaccount}'
#with
$username = "QAMR-ACCOUNTS\${bamboo.yaccount}"

#replace
$password = '${bamboo.ypassword}'
#with
$password = ${bamboo.ypassword}

See here about quoting rules