Created
May 13, 2020 19:55
-
-
Save luismanez/7cdba8d40691b21cafabd7a71e9e0b95 to your computer and use it in GitHub Desktop.
Trying to hack SharePoint Online to Configure Site Collection Tenant default timezone (context here: https://twitter.com/cann0nf0dder/status/1260607421111767042)
This file contains 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
# THIS IS NOT WORKING. It´s raising a Bad Request response, but it might be possible with more testing | |
# and setting more Headers required by the API. | |
# You can do the Update from Admin centre, and get the request is done by the Page using Browser dev tools | |
#FIRST do Connect-PnPOnline to your tenant admin URL... | |
$url = "https://tenant-admin.sharepoint.com/" | |
$endpoint = "https://tenant-admin.sharepoint.com/_api/SPOInternalUseOnly.TenantAdminSettings" | |
$webCtx = (Get-PnPWeb).Context | |
$authCookie = $webCtx.Credentials.GetAuthenticationCookie($url, $true) | |
$digest = $webCtx.GetFormDigestDirect().DigestValue | |
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession | |
$session.Cookies.SetCookies($url, $authCookie) | |
$session.Headers.Add("X-RequestDigest", $digest) | |
$itemPayload = @{"TenantDefaultTimeZoneId" = @{"Value" = 3}} | |
try { | |
Invoke-WebRequest -Uri $endpoint -Method PATCH -ContentType 'application/json; charset=utf-8' -WebSession $session -Body $itemPayload | |
} catch { | |
$err=$_.Exception | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment