SOLVED

Connect-PnPOnline credential: can it use SharePointOnlineCredentials object

Iron Contributor

$UserName="<username>"

$pwd ="<password>"

$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $pwd -AsPlainText -Force))

 

can we use the above credentials inside the bracket below

 Connect-PnPOnline –Url $SiteUrl –Credentials (Get-Credential)

1 Reply
best response confirmed by null null (Iron Contributor)
Solution

You can either do this:

 

$cred = Get-Credential -UserName $username -Message "Please enter password for $username"

or this:

 

$encpassword = convertto-securestring -String $password -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword

and then connect with:

 

Connect-PnPOnline -Url $destinationTenantUrl -Credentials $cred
1 best response

Accepted Solutions
best response confirmed by null null (Iron Contributor)
Solution

You can either do this:

 

$cred = Get-Credential -UserName $username -Message "Please enter password for $username"

or this:

 

$encpassword = convertto-securestring -String $password -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword

and then connect with:

 

Connect-PnPOnline -Url $destinationTenantUrl -Credentials $cred

View solution in original post