How to secure guest links

In SPO, we have a little problem, because when we invite an external user to our tenant, this person will receive an invitation, but he/she can decide whether use it or not, and instead of using it, forward the invitation to someone else to access the site or document.

So to prevent this, we can use the following PowerShell:

Set-SPOTenant -RequireAcceptingAccountMatchInvitedAccount $true

This will require that only the owner will have access 🙂

Cheers!

How to delete sites from SPO recycle bin

By default, when you delete a SharePoint Online site collection from the SharePoint admin center, it is moved to the Recycle Bin, where it is retained for a 30-day period. But, what if you don’t want to wait 30 days? Or you need the quota that the site collection has or even you need to create a new SC with the same url? To all those question, PowerShell is your answer, so let’s begin:

$cred=get-credential

$siteAdminURL = “https://yourtenanturl-admin.sharepoint.com”

Import-Module Microsoft.Online.SharePoint.PowerShell

connect-sposervice -url $siteadminurl -credential $cred

Get-SPODeletedSite | foreach {
Write-host “Deleting ” $_.Url
Remove-SPODeletedSite –Identity $_.Url –Confirm:$false
}

Master Page Gallery Access Denied

Today, a colleague was working in some customizations in SharePoint Online and he needed to access to the Master Page Gallery, he could access using the url, but when he tried to upload files he received the typical Access denied message.

I catch an eye to this weird behaviour and I realized that this was happening for any Site Collection administrator, so what was happening? tracking the issue we were able to discover by Check permission that the permission of “Adding or Customizing Pages” was denied in that library.

So my next step was to check if the scripting capabilities were turned on, in our case how the tenant was new the feature was set to Prevent, so I changed it to Allow

scripting-capabilities

MS says that it is necessary to wait at least 24 hours to see the changes, but if you’re in a hurry and don’t want to waste your time, open your PowerShell Shell and execute the following:

Set-SPOsite “https://urltenant.sharepoint.com” -DenyAddAndCustomizePages 0

Once executed, the option of master page gallery will appear in the settings panel, so my colleague could continue with his work.

Hope it helps!

How to change regional settings with PowerShell

Recently I needed to change the regional settings for all the sites and site collection in a SharePoint 2013 farm, so I did it with Powershell.

But also, at the same time I needed to do it for a SPO tenant, so let’s PowerShell!

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
foreach ($webApplication in Get-SPWebApplication) {
Write-Host
Write-Host "Processing $webApplication"
Write-Host "******************************"

foreach ($site in $webApplication.Sites) {
$webs = $site.AllWebs
Write-Host
Write-Host "Processing $site"
Write-Host "******************************"
foreach ($web in $webs) {
$culture=[System.Globalization.CultureInfo]::CreateSpecificCulture("es-es")
$web.Locale=$culture
$web.Update()
$web.Dispose()
Write-Host $web.Url
}
}
}

#If you need to change the timezone and local id in SharePoint Online, you can do it using the following:

#This is to change the LocalID
#First, set up your ClientContext in the normal manner:
$Password = ConvertTo-SecureString -String "yourPassword" -AsPlainText -Force;
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/sites/yourSiteCollection");
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("admin@company.onmicrosoft.com", $Password);
#Now we need to set up our target web site object:
$web = $ctx.Web;
$ctx.Load($web);
$ctx.ExecuteQuery();
#Next, update the settings. In this example, I’m setting the LocaleId to 2057 (en-UK)
$web.RegionalSettings.LocaleId = 2057;
$web.Update();
#Finally, run the ExecuteQuery method to apply the changes:
$ctx.ExecuteQuery();

#The following is to change the zoneID for personal sites
if($user.LoginName.Contains('@'))
{
$persweb=$user.LoginName.Replace(".","_").Replace("@","_")
$persweb=$myhost+"/personal/"+$persweb
Write-Host $persweb
Set-SPOUser -Site $persweb -LoginName $username -IsSiteCollectionAdmin $true
$AdminUrl=$persweb

Set-SPoUserRegionalSetings -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -TimeZoneID $TimeZoneID
}

If you need to know which time zone ID is your region, visit: https://gist.github.com/mj1856/9542228 to check it

And If you need to check your local ID, visit: https://msdn.microsoft.com/en-gb/goglobal/bb964664

Ref: https://blogs.technet.microsoft.com/fromthefield/2015/04/13/office-365-change-the-locale-of-all-onedrive-for-business-sites-using-powershell/
https://gallery.technet.microsoft.com/Update-the-time-zones-in-67a5644a

SPO – How to set storage quota

Imagine you have a webapplication where all the users are allowed to upload all the documentation that they want, you know that users love free space, so they will upload as much files as they can, but may be situations or business decisions when is it necessary to put on a quota to restrict the space that users can use.

For example, if you want to know what storage quota do you have for a particular site, you will need to navigate to Site settings –> Site Metrics

sm1

But, if you want to set a quota limit in SPO, you will need PowerShell to do that, so let’s begin

Execute the following:

$cred = get-credentials

Set-SPOSite –Identity https://urlappweb/yoursite -StorageQuota 512000 -credentials $cred

Once the PS has been executed, you can verify the quota that has been set

sm2

Happy SharePointing!