Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Last active June 27, 2019 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/c8eb0bcb385c9a620d5eb734ec9682b1 to your computer and use it in GitHub Desktop.
Save mirontoli/c8eb0bcb385c9a620d5eb734ec9682b1 to your computer and use it in GitHub Desktop.
#Connect Disconnect
#https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps
$adminUPN="admin@takana15.onmicrosoft.com";
$orgName="takana15";
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password.";
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential;
#oneliner:
Connect-SPOService -Url https://takana15-admin.sharepoint.com -Credential (Get-Credential -UserName spadmin@takana15.onmicrosoft.com -Message "psw")
Disconnect-SPOService
# https://sharepoint.handsontek.net/2018/10/28/enable-custom-script-on-modern-sharepoint-sites-using-powershell/
Set-SPOSite -Identity https://takana15.sharepoint.com/sites/try-custom-script -DenyAddAndCustomizePages 0
# Create Sites
$orgName="takana15";
$urlPath = "https://$orgName.sharepoint.com/sites"
$owner = "admin@$orgName.onmicrosoft.com"
$tz = 4; # Stockholm
$lcid = 1033; # English
New-SPOSite -LocaleID $lcid -Owner $owner -TimeZoneId $tz -Url "$urlPath/assets" -Title "Assets" -StorageQuota 1000 -Template "STS#3"
New-SPOSite -LocaleID $lcid -Owner $owner -TimeZoneId $tz -Url "$urlPath/demo1" -Title "Demo 1" -StorageQuota 5120 -Template "ENTERWIKI#0"
Connect-PnPOnline https://takana15-admin.sharepoint.com
# Add Site Collection App Catalog
# https://docs.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog
# Prerequisite: Tenant Admin or SP Admin + your account should be Site Collection Administrator on the Tenant App Catalog:
# $appcatalog Get-PnPTenantAppCatalogUrl
# Set-SPOUser -Site $appcatalog -LoginName spadmin@takana15.onmicrosoft.com -IsSiteCollectionAdmin $true
Add-SPOSiteCollectionAppCatalog -Site https://takana15.sharepoint.com/sites/julafton011
# SPO Admin scripts
# https://laurakokkarinen.com/my-most-used-powershell-scripts-for-managing-sharepoint-online/
# Web Api Permission Requests
# https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient#manage-permissions-with-powershell
Get-SPOTenantServicePrincipalPermissionRequests
Get-SPOTenantServicePrincipalPermissionGrants
# Approve
Approve-SPOTenantServicePrincipalPermissionRequest -RequestId fcc1a84a-f5ba-42c0-9c33-62a79fe709e8
# Remove a request: https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/deny-spotenantserviceprincipalpermissionrequest?view=sharepoint-ps
Deny-SPOTenantServicePrincipalPermissionRequest -RequestId 190f0e51-1b76-4f87-89c7-dd41c48e5861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment