Sunday, October 6, 2019

Increase Quota for Site Collection in SharePoint Online using PowerShell

connect-sposervice https://ajtech-admin.sharepoint.com

get-sposite -identity https://ajtech.sharepoint.com/sites/testsite

Set-SPOSite https://ajtech.sharepoint.com/sites/gp -StorageQuota 2000 -StorageQuotaWarningLevel 1500

#Check quota after increasing the size

get-sposite -identity https://ajtech.sharepoint.com/sites/gp

Remove Site Collection from Recycle Bin in SharePoint Online using PowerShell

connect-SPOService -url "https://ajtech-admin.sharepoint.com"
Remove-SPODeletedSite -Identity https://ajtech.sharepoint.com/sites/testsite


Giving Access/Admin Rights to OneDrive account using PowerShell

Connect-SPOService -Url https://ajtech-admin.sharepoint.com -credential ajadmin@ajtech.com

$site = Get-SPOSite -Identity "https://ajtech-my.sharepoint.com/personal/aj_user1_ajtech_com"
Set-SPOUser -Site $site.Url -LoginName ajuser2@ajtech.com -IsSiteCollectionAdmin $true

Lock/Unlock the site Collection in SharePoint Online using PowerShell

#Connect to SP Online
Connect-SPOService -Url https://ajtech-admin.sharepoint.com -credential ajadmin@ajtech.com

#get site collection that you want to lock/unlock
$site = "https://ajtech.sharepoint.com/sites/test"

#Lock the Site collection
Set-SPOSite -Identity $site -Lockstate "NoAccess"

#Unlock the Site collection
Set-SPOSite -Identity $site -Lockstate "Unlock"

Increase Quota for One Drive using PowerShell



#Increasing Quota

Connect-SPOService -Url https://ajtech-admin.sharepoint.com -credential ajadmin@ajtech.com Set-SPOSite -Identity https://ajtech-my.sharepoint.com/personal/aj_tech_ajtech_com -StorageQuota 5268436

User Alerts on Lists/Libraries in SharePoint site collection using PowerShell

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$output = "C:\useralerts.csv";
$SPSiteCollection = Get-SPSite “http://2010.ajtech.com”
$alertcount=0
$test = " "
foreach($SpWeb in $SPSiteCollection.AllWebs)
{
foreach($alert in $SpWeb.Alerts)
{
$alertcount += 1

$alert.AlertFrequency | Out-File -Encoding Default -Append -FilePath $Output;
$alert.user.userlogin | Out-File -Encoding Default -Append -FilePath $Output;
$spweb.url | Out-File -Encoding Default -Append -FilePath $Output;
$alert.ListUrl | Out-File -Encoding Default -Append -FilePath $Output;
$alert.Title | Out-File -Encoding Default -Append -FilePath $Output;
$test | Out-File -Encoding Default -Append -FilePath $Output;

}
}

"alert count is :" + $alertcount | Out-File -Encoding Default -Append -FilePath $Output

List of sites under Web App with Last modified date in SharePoint using PowerShell

Add-PSSnapin Microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$Webapp = "http://2010.ajtech.com"
$site = Get-SPSite -webapplication $Webapp -Limit All
$site | Get-SpWeb -Limit All |Select-Object -Property LastItemModifiedDate, URL | Export-Csv -path C:\siteslistlastmodified.csv