Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Thursday, February 12, 2015

You have reached the maximum resource usage limit

Our organization's O365 tenancy has a lot of Global Administrators.
Global admins have the ability to set among other things, SharePoint Site Collection Storage Quotas and the often misunderstood Server Resource Quota.

There has been misunderstood thought that by increasing this setting to some really big number, their site collection will have blazingly fast performance and every other site collection will chug along at their slow dial-up rate.

This is not at all true, and in fact you can really mess things up by setting these numbers too high.

Consider this:
A Site Collection is created and then assigned a huge number of resources. Then it is deleted.
This happens a few times and before long, your SharePoint Admin Center displays this ugly error and you are unable to manage resources on any of the collections.

You have reached the maximum resource usage limit. - Well dang!


And... you can't increase or decrease any site collection resource! Sort of a Catch 22, right? So you decide to start deleting site collections thinking this might help!




You would expect those resources to free up since you deleted them, right? But they just don’t and that mean ol' red bar stays red.

The deleted collection is in the Site Collection Recycle bin. Those resources are not reallocated just because you deleted it. They are still awaiting to be purged and those resources need to stay allocated until then.

 So what do you do?

PowerShell to the rescue!
Here is what we had to do to return our site back to normal.

First, query the site owners and ask if they have any sandboxed or custom code on their sites and need those extra resources to debug or step thought their code.
 If they do, understand their burden and pity them. Leave them to their debugging, and focus on the deleted sites and the sites where there is no custom code.

Then fire up a SharePoint Online or Azure PowerShell command prompt and connect to your admin portal,
connect spo-service http://contoso-admin.sharepoint.com 
…notice the -admin, it’s the URL of the admin portal.

Authenticate with a Global Admin account.

Open the admin console and look in the Site Collection recycle bin:

 

Grab the URL of a deleted site.
Then delete it, with extreme prejudice.
Remove-SPODeletedSite -Identity [URL of site in recycle bin]

Do this for each site in the recycle bin.

When that’s done, the ugly error "You have reached the maximum blah blah" and red bar ought to go away!

Nbow you need to attempt to set the resource quota for one of those collections that are set to some large number.
You might try reassigning it in the admin portal, but what fun is that? You still have that console open, so…
Set-SPOSite -Identity https://BigSite/sites/ituneslibrary  -ResourceQuota 300

Now all should be right in the world.

The resource usage quota is a site collection metric calculated by SharePoint Online. The main purpose of resource quotas is to limit the risk that sand-boxed custom code can have on available resources on a site collection, bad code causing excessive CPU use for example.

The actual resource quota used to be determined by the number of user seats in your company's subscription (#seats×200) +300 (may have changed now). 

So for a 10 seat license, the resource quota would be 2300 split across all site collections you own

HopeThisHelps,

John

Tuesday, October 1, 2013

How to configure passwords to never expire in O365

Install the Windows Azure AD Module

You must install the appropriate version of the Windows Azure AD Module for Windows PowerShell for your operating system from the Microsoft Download Center:
Windows Azure Active Directory Module for Windows PowerShell (32-bit version)
Windows Azure Active Directory Module for Windows PowerShell (64-bit version)

Start the Windows Azure Active Directory Module for Windows PowerShell


Connect to Windows Azure Active Directory

Type connect-msolservice …and log in with your admin account
Review: the TechNet Article for a list of available commands
http://technet.microsoft.com/library/jj151815.aspx

Run the following command to GET a specific user's Password Expiration Policy:
Get-MSOLUser -UserPrincipalName user@company.com | Select PasswordNeverExpires

Run the following command to GET ALL User's Password Expiration Policy:

Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
Run the following command to SET a User's Password Expiration Policy:

Set-MsolUser -UserPrincipalName [user@company.com -PasswordNeverExpires $true



TIP: if you love Get-Help then you will need to add it: 

To create a folder for help, list the cmdlets, and then open the file in notepad, you can run the following commands at the Windows PowerShell command prompt:
new-item c:\MSOLHelp -type directory
get-command | Where-Object {$_.name -like "*msol*"} | format-list | Out-File c:\MSOLHelp\msolcmdlets.txt
notepad c:\MSOLHelp\msolcmdlets.txt

Monday, August 5, 2013

Export Solutions from farm

Recently a client 'accidentally' deleted the solutions that we installed on their farm.
Not from SharePoint, but the actual wsp files that we copied to their server. 
These are useful to have in case someone 'accidentally' removed the solution.
We can recover installed solutions from Powershell.



$dirName = "e:\exportedfiles"

foreach ($solution in Get-SPSolution)
{
$id = $Solution.SolutionID
$title = $Solution.Name
$filename = $Solution.SolutionFile.Name

try {
$solution.SolutionFile.SaveAs("$dirName\$filename")
Write-Host " – done" -foreground green
}
catch
{
Write-Host " – error : $_" -foreground red
}
}


This will populate your $dirName with wsp files from the farm.Files are now back, and you dont need to restore the VM!

Friday, June 7, 2013

PowerShell Online

Set up the SharePoint Online Management Shell environment for SharePoint Online global administrators.
Love It!

Perform the following:


Try it out! For example, run Get-SPOSite to get a list of all sites.

Friday, March 15, 2013

Get the site contents size in PowerShell

Love this!
Get the site contents size. Particularly useful in prep for a move.



Get-SPSite | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | ConvertTo-Html "Site Colleections sort by size" | Set-Content sitesize.html

Thursday, February 14, 2013

Last User Login to Current Computer

Last User Login to Current Computer. Love this. Give me a list of domain users and their last login time to the current computer.

$data = @()
$NetLogs = Get-WmiObject Win32_NetworkLoginProfile
foreach ($NetLog in $NetLogs) {
if ($NetLog.LastLogon -match "(\d{14})") {
$row = "" | Select Name,LogonTime
$row.Name = $NetLog.Name
$row.LogonTime=[datetime]::ParseExact($matches[0], "yyyyMMddHHmmss", $null)
$data += $row
}
}

$data

Last Windows Domain logon time

Last Windows Logon Time
Love this.
This script uses the DirectorySearcher object to search for all users in Active directory. It then walks through the user accounts and determines the last logon date. 
The key point of the script is translating the [int64] number into something that can be read.

$searcher = New-Object DirectoryServices.DirectorySearcher([adsi]"")
$searcher.filter = "(objectclass=user)"
$users = $searcher.findall()
Foreach($user in $users)
{
if($user.properties.item("lastLogon") -ne 0)
{
$a = [datetime]::FromFileTime([int64]::Parse($user.properties.item("lastLogon")))
"$($user.properties.item(`"name`")) $a"
}

}

Got this from the Technet script center:

Tuesday, October 9, 2012

Detect the installed SharePoint edition

get-spfarm | select Products





See the article How To: Detect the Installed SKU of SharePoint 2010 on MSDN. It has a list of GUIDs for each SKU:
  • BEED1F75-C398-4447-AEF1-E66E1F0DF91E: SharePoint Foundation 2010
  • 1328E89E-7EC8-4F7E-809E-7E945796E511: Search Server Express 2010
  • B2C0B444-3914-4ACB-A0B8-7CF50A8F7AA0: SharePoint Server 2010 Standard Trial
  • 3FDFBCC8-B3E4-4482-91FA-122C6432805C: SharePoint Server 2010 Standard
  • 88BED06D-8C6B-4E62-AB01-546D6005FE97: SharePoint Server 2010 Enterprise Trial
  • D5595F62-449B-4061-B0B2-0CBAD410BB51: SharePoint Server 2010 Enterprise
  • BC4C1C97-9013-4033-A0DD-9DC9E6D6C887: Search Server 2010 Trial
  • 08460AA2-A176-442C-BDCA-26928704D80B: Search Server 2010
  • 84902853-59F6-4B20-BC7C-DE4F419FEFAD: Project Server 2010 Trial
  • ED21638F-97FF-4A65-AD9B-6889B93065E2: Project Server 2010
  • 926E4E17-087B-47D1-8BD7-91A394BC6196: Office Web Companions 2010
You can look for these within the registry key HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\InstalledProducts.

You can also use the PowerShell command get-spfarm | select Products to output GUIDs for the installed SKUs.

Saturday, September 29, 2012

Move a site to another location

Move a site to another location
stsadm -o renameweb -url http://spfarm/subsite -newname spfarm/othersubsite

SharePoint Content DB privileges

Grant user db_owner privileges on the content database associated with that web application.
This can be done either manually (using the UI) or via PowerShell.

PS> $w = Get-SPWebApplication("webappname")
PS> $w.GrantAccessToProcessIdentity("domain\supsvc")

SharePoint Needs Upgrade???

SharePoint Needs Upgrade???
(get-spserver $env:computername).NeedsUpgrade


Find user Profile Application GUID in Sharepoint

Find user Profile Application GUID in Sharepoint $sts = Get-SPServiceApplication | ?{$_ -match "user"}

PowerShell Editor and Secuity

Change Security Policy to Allow users to create powershells and run them
Set-ExecutionPolicy Unrestricted

To get the Powershell Editor on Win2008 R2 server…
Import-Module ServerManager
Add-Windowsfeature PowerShell-ISE

Pasted from <http://www.jonathanmedd.net/2011/02/powershell-ise-not-installed-by-default-in-windows-server-2008-r2.html>

Anonymous Site Access and Site Lockdown

If you need to lock down a SharePoint site collection for additions, but still allow updates and deletions, what do you do?


Use the following cmdlet in PowerShell:
Set-SPSite –Identity <SiteCollection> -LockState NoAdditions


If you setup anonymous access for a web app to the internet there is a way to lock down anon users from seeing allitems and editform pages while still letting them gain access to other areas.  What is this?

You must activate the ViewFormPagesLockDown feature:

To disable, run this Shell command:
$lockdown = get-spfeature viewformpageslockdown

disable-spfeature $lockdown -url http://sitecollectionURL