src/Get-CciVstsCredential.ps1
function Get-cciVstsCredential { [CmdletBinding()] param ( $subscriptionName, $keyvaultName, $secretName, $patusername ) begin { Write-Verbose "Started running $($MyInvocation.MyCommand)" } process { $null = Connect-AzAccount -SubscriptionName $subscriptionName -Credential (Get-Credential) $secretValue = (Get-AzKeyVaultSecret -VaultName $keyvaultName -Name $secretName).SecretValueText $pat = ConvertTo-SecureString $secretValue -AsPlainText -Force New-Object PSCredential -ArgumentList $patusername, $pat } end { Write-Verbose "Finished running $($MyInvocation.MyCommand)" } } |