Skip to content

Commit 0d39899

Browse files
Add files via upload
1 parent 03934e9 commit 0d39899

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
57.2 KB
Loading
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function Get-SiteColl
2+
{
3+
param (
4+
[Parameter(Mandatory=$true,Position=1)]
5+
[string]$Username,
6+
[Parameter(Mandatory=$true,Position=2)]
7+
[string]$Url,
8+
[Parameter(Mandatory=$true,Position=3)]
9+
$password
10+
)
11+
12+
13+
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url)
14+
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
15+
$ctx.Load($ctx.Web)
16+
$ctx.ExecuteQuery()
17+
18+
$spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx)
19+
$ctx.Load($spoTenant)
20+
$ctx.ExecuteQuery()
21+
22+
Write-Output $spoTenant
23+
24+
}
25+
26+
27+
28+
29+
#Paths to SDK
30+
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
31+
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"
32+
#Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.AllowLimitedAccess
33+
34+
35+
#Enter the data
36+
$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString
37+
$username="admin@TENANT.onmicrosoft.com"
38+
$Url="https://TENANT-admin.sharepoint.com"
39+
40+
41+
42+
43+
Get-SiteColl -Username $username -Url $Url -password $AdminPassword

0 commit comments

Comments
 (0)