-
Notifications
You must be signed in to change notification settings - Fork 38
Description
I'm trying to figure how to use a "Secret" variable with the PowerShell++ Inline Script.
Is it possible ?
Here's what I tried so far.
The secret variable is named deploymentPassword
Test 1:
Write-Host "Encrypting the Password"
Write-Host "Creating the Credential Object"
$cred = New-Object -TypeName "System.Management.Automation.PSCredential"( "TENANTDEV\SVC-TFS-DV-DEPLOY", $secpasswd )
I get this error:
Encrypting the Password
##[error]Cannot process command because of one or more missing mandatory parameters: String.
Test 2:
Write-Host "Encrypting the Password"
Write-Host "Creating the Credential Object"
$cred = New-Object -TypeName "System.Management.Automation.PSCredential"( "TENANTDEV\SVC-TFS-DV-DEPLOY", $secpasswd )
I get this error:
Encrypting the Password
##[error]Cannot process command because of one or more missing mandatory parameters: String.
Test 3:
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
Write-Host "Reading from TFS Variable"
$password = Get-TaskVariable -Context $distributedTaskContext -Name "deploymentPassword"
Write-Host "Creating the Credential Object"
$cred = New-Object -TypeName "System.Management.Automation.PSCredential"( "TENANTDEV\SVC-TFS-DV-DEPLOY", $password )
I get this error:
Creating the Credential Object
##[error]Cannot find an overload for "PSCredential" and the argument count: "2".
Test 4:
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
Write-Host "Reading from TFS Variable"
$password = Get-TaskVariable -Context $distributedTaskContext -Name "deploymentPassword"
Write-Host "Securing value"
Write-Host "Creating the Credential Object"
$cred = New-Object -TypeName "System.Management.Automation.PSCredential"( "TENANTDEV\SVC-TFS-DV-DEPLOY", $secpasswd )
I get this error:
Securing value
##[error]Cannot process command because of one or more missing mandatory parameters: String.