0

I have created a azure release pipeline. In order for that to work I have made app registration and created certificate. The method I am using to connect right now is as following: Connect-PnPOnline -Url $sharepointside -ClientId $id -Tenant $Tenant -CertificateBase64Encoded $encoded -CertificatePassword $password

I went this method because this way I don't have to upload the certificate to my azure devops. But I have some concern about storing the certificate password in the variable. Is there way I can connect to sharepoint from azure pipeline without using password variable? Or any idea on other options I can use?

2
  • 1
    If you are asking for a safe place to store the password, why not add it as a secret in a azure key vault? Easy to retrive using PowerShell, but will take some extra steps/time. Feb 19, 2022 at 8:45
  • Thanks for the suggestion,@christoffer. I have now created azure key vault but I am having trouble getting the variable value when using powershell type FilePath. It works fine with powershell type Inline. Any suggestion? sharepoint.stackexchange.com/questions/300600/…
    – hellothere
    Feb 21, 2022 at 18:23

1 Answer 1

0

I can only suggest you 2 ideas.

First, the easiest, you can use the Get-PnPStoredCredential command which you need to use the Windows Credential Manager in Control Panel safely.

$cred = Get-PnPStoredCredential -Name myCredential
#supply the $cred.Password to the command

Secondly, you can use the command that I have used a lot, convert from and to SecureString. But it's also best to keep the current Windows account password safe, as it'll be encrypted with the current username as the key.

$ssPassword = Read-Host -AsSecureString
#Then type your password
$ss = ConvertFrom-SecureString $ssPassword
Set-Content -Path ".\password.pwd" -Value $ss

Then you can store the $ss in a text file. To use it, see below.

$ssPassword = ConvertTo-SecureString (Get-Content -Path ".\password.pwd")
#supply the $ssPassword to the command

That's all. Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.