Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save luismanez/7cdba8d40691b21cafabd7a71e9e0b95 to your computer and use it in GitHub Desktop.
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 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