Created
March 27, 2019 07:48
-
-
Save OlafD/2d52bde7d0e1ce6ce46c599fcf09a559 to your computer and use it in GitHub Desktop.
Simple starter für a PowerShell script, when needed to connect to the SharePoint Online site. Can work with credentials or web login.
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
param ( | |
[Parameter(Mandatory=$true)] | |
$Url, | |
$Cred, | |
[switch]$UseWebLogin | |
) | |
if ($UseWebLogin.ToBool() -eq $false) | |
{ | |
if ($Cred -eq $null) | |
{ | |
$Cred = Get-Credential | |
} | |
Write-Host "Connect to $Url using credentials" | |
Connect-PnPOnline -Url $Url -Credentials $Cred | |
} | |
else | |
{ | |
Write-Host "Connect to $Url using webLogin" | |
Connect-PnPOnline -Url $Url -UseWebLogin | |
} | |
# your code here... | |
Write-Host "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment