Created
December 20, 2023 15:21
-
-
Save OlafD/85826ba77df8509d550a79ed2df94c0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding(DefaultParameterSetName = "Interactive")] | |
param ( | |
[Parameter(Mandatory, ParameterSetName = "UserPassword")] | |
[Parameter(Mandatory, ParameterSetName = "Interactive")] | |
[Parameter(Mandatory, ParameterSetName = "AppIDCertificate")] | |
[string] $Url, | |
[Parameter(Mandatory, ParameterSetName = "UserPassword")] | |
[pscredential] $Credentials, | |
[Parameter(Mandatory, ParameterSetName = "AppIDCertificate")] | |
[string] $ClientID, | |
[Parameter(Mandatory, ParameterSetName = "AppIDCertificate")] | |
[string] $CertificatePath, | |
[Parameter(Mandatory, ParameterSetName = "AppIDCertificate")] | |
[securestring] $CertificatePassword | |
) | |
Write-Verbose -Message ("Trying to connect with method " + $PSCmdlet.ParameterSetName) | |
Write-Verbose -Message ("Connect to " + $Url) | |
switch ($PSCmdlet.ParameterSetName) | |
{ | |
"Interactive" | |
{ | |
Connect-PnPOnline -Url $Url -Interactive | |
} | |
"UserPassword" | |
{ | |
Connect-PnPOnline -Url $Url -Credentials $Credentials | |
} | |
"AppIDCertificate" | |
{ | |
Connect-PnPOnline -Url $Url -ClientId $ClientID -CertificatePath $CertificatePath -CertificatePassword $CertificatePassword | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment