Monthly Archives: June 2012

Setting the default 3 groups in SharePoint from PowerShell

I ran into this today –

Tagging on /_Layouts/permsetup.aspx to a site’s url brings up a list of the 3 standard groups for a site:

  • one for visitors
  • one for members
  • one for owners

Today when I tried to change one through the GUI, It threw an error.
The ULS logs were a mess, and not wanting to loose a day opening a case with MS I tried PowerShell.

The solution is fairly easy.
Grab a pointer to the web in question with:

$web = get-spweb http://www.yoururl.com/sites/MainSite/subsite

You can see all the web’s properties with:

$web | fl

The 3 that we’re interested in are:

  • AssociatedVisitorsGroup
  • AssociatedMembersGroup
  • AssociatedOwnersGroup

We can set these with PowerShell easily:

$web.AssociatedVisitorsGroup = $web.SiteGroups["Nameofthegroup"]
$web.update()

A list of Sharepoint Virtual File paths

This will start out to be an incomplete list, but should grow with time.
Last update Feb 10th 2016.

These are links that are sometimes handy to have when the UI doesn’t display them.

Path and file explanation
_layouts/viewlists.aspx Same as site actions->View all content
_catalogs/masterpage/Forms/AllItems.aspx View master pages for this site collection.
_layouts/changesitemasterpage.aspx Changes the master page for the site collection (must be called from the site collection url, not a subweb url)
_layouts/permsetup.aspx assings the 3 magic groups to a sharepoint web called from a web or subweb url
_layouts/chkperm.aspx Check user permissions and group membership in given Web *
_catalogs/lt/Forms/AllItems.aspx List template Gallery
_catalogs/solutions/Forms/AllItems.aspx Site Template (/Solutions) Gallery
_catalogs/users/simple.aspx This looks at the secret internal users list on a site collection – I had to do this once when dealing with an Active Directory migration and having duplicate users show up when they should not.
_layouts/settings.aspx Site Settings
_layouts/user.aspx A list of all groups and users in a given Site
_layouts/groups.aspx A list of all groups in a given Site Collection
_layouts/AreaTemplateSettings.aspx This screen chooses what site templates are available when creating a new site in a given site collection
_layouts/quiklnch.aspx An almost odd list view of the quick launch items –
but not the one you get to from site settings.
This is linked to from the “getting started” web part.
_layouts/qlreord.aspx Same as above – this one lets you sort the quick launch items.
_layouts/AdminRecycleBin.aspx End User Recycle Bin.
_layouts/AdminRecycleBin.aspx?View=2 Deleted from End User Recycle Bin.
Pagename.aspx?contents=1 View the web parts on a page – good for times when a web part keeps a page from rendering in normal mode.
_Layouts/appinv.aspx view details about an app (2013/2016/SPO)

* Thanks to reader Jacek Bulwan for submitting this one!

Get all sharepoint users users in the farm with Powershell to a CSV file

This is a script that gets each sharepoint site on the farm, enumerates all the site collections and webs and dumps them to the screen as well as a CSV file.

The Current date and time is always appended to the file name so you don’t have to worry about wiping out previous results.

#getalluserseverywhere
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$timestamp = get-date -format "yyyyMMdd_hhmmtt"
$filenameStart = "AllFARMUsers"
$logfile = ("{0}{1}.csv" -f $filenamestart, $timestamp)

$header = "type,user,group,weburl,webname"
$header | out-file -FilePath $logfile

$iissitelist = get-spwebapplication 
foreach($onesite in $iissitelist)
{

	foreach ($SiteCollection in $onesite.sites)
	{
		write-host $SiteCollection -foregroundcolor Blue	
		foreach ($web in $SiteCollection.Allwebs)
		{ 
			 write-host "    " $web.url $web.name "users:" -foregroundcolor yellow
			 # Write-host "        " $web.users | select name 
			 foreach ($userw in $web.users)
			 {
				#if ($userw -like "domain*")
				#{
					write-host "        " $userw -foregroundcolor white
					#$msg = ("{0},{1} user:{2}" -f $web.url,$web.name, $userw)
					$msg = ("RootUser,{0},-,{1},{2}" -f $userw, $web.url,$web.name) 
					$msg | out-file -FilePath $logfile  -append
				#  }
			   }


			 foreach ($group in $web.Groups)
			{
						Write-host "        " $web.url $group.name: -foregroundcolor green
				 foreach ($user in $group.users)
				 { 
					# if ($user -like "Domain*")
					 #{   
						  Write-host "            " $user -foregroundcolor white
						  #$msg = ("{0},{1},group:{2}, user:{3}" -f $web.url, $web.name, $group, $user)
						  $msg = ("GroupUser,{0},{1},{2},{3}" -f $user, $group, $web.url, $web.name)
						  $msg | out-file -FilePath $logfile  -append
					 #}
				 }
			}	
			$web.Dispose()
		}
	  
	}
}