Skip to content

Instantly share code, notes, and snippets.

@cmd64
Last active August 19, 2021 13:28
Show Gist options
  • Save cmd64/da0f1cf3509f88e96f13d41a12a60c2b to your computer and use it in GitHub Desktop.
Save cmd64/da0f1cf3509f88e96f13d41a12a60c2b to your computer and use it in GitHub Desktop.
[Powershell] Anonymous Users cannot open XLSX files from a document library
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "<site collection URL>";
$site = New-Object Microsoft.SharePoint.SPSite($siteurl);
$web = $site.OpenWeb();
$enumPerms = [Microsoft.SharePoint.SPBasePermissions];
Write-Host $web.AnonymousPermMask64;
$web.AnonymousPermMask64 = $enumPerms::ViewListItems -bor $enumPerms::ViewVersions -bor $enumPerms::ViewFormPages -bor $enumPerms::Open -bor $enumPerms::ViewPages -bor $enumPerms::UseClientIntegration -bor $enumPerms::OpenItems
$web.Update();
Write-Host $web.AnonymousPermMask64;
$web.Dispose();
$site.Dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment