Solution
$userName = 'test-domain\test-login' $password = 'test-password' $pwdSecureString = ConvertTo-SecureString -Force -AsPlainText $password $credential = New-Object -TypeName System.Management.Automation.PSCredential ` -ArgumentList $userName, $pwdSecureString For Build Machines
In the previous code replace user name and password values by secret ("hidden from logs") environment variables of your build-machine
Test results by adding
'# Results' $credential.GetNetworkCredential().Domain $credential.GetNetworkCredential().UserName $credential.GetNetworkCredential().Password and you'll see
# Results test-domain test-login test-password