#Pridani knihoven pro praci
Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll”
Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll”
#Zadefinovani uzivatele a hesla
$Username = Read-Host -Prompt “Please enter your username”
$Password = Read-Host -Prompt “Please enter your password” -AsSecureString
$Site = “https://nazevtenantu.sharepoint.com”
#Pripojeni k tenantu a ziskani verze
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
$Context.Credentials = $Creds
$Context.ExecuteQuery()
Write-Host “Server Version:” $Context.ServerVersion -ForegroundColor Green