create a list of groups and the users in each group

As we all know, digging through SharePoint groups looking to see what users are in each, is no fun.

To solve this, I created a new List, and added the groups I wanted to monitor.  Then, added a little PowerShell to update a column in the List with the members in each group.

Setup:

Create a new List.

New Columns:

SPgroup 

Type: Person or Group

Allow selection of: People or Group

Users

Type: Multiple lines of text

Specify the type of text to allow: 

Update Column:

Title

Require that this column contains information: No

The PowerShell script below does the following:

Get the SharePoint Site and List.

Loop through each item in the List.

Retrieve the value of the SPgroup field.

Truncate the Users field.

Loop through the users in the SPgroup.

Update the Users field with the values from SPgroup.


if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$sSite = Get-SPweb "http://reinmoto.com/sites/taco"
$sList=$sSite.Lists["SP Group Permissions"]
$i = 0

foreach($item in $sList.Items)
{
	$sFieldValue = $item["SPgroup"].ToString().Split('#')[1]
	$sGroup = $sSite.SiteGroups[$sFieldValue]

	If($sGroup.Users.Count -ge 0)
	{
		$item["Users"] = ""
		$item.Update()

		foreach($usr in $sGroup.Users)
			{
				if($i -eq 0)
				{
					$item["Users"] = $usr.DisplayName
				}
				else
				{
					$item["Users"] = $item["Users"] + ", " + $usr.DisplayName
				}
				$item.Update()
				$i=$i+1
			}
		$i=0
	}
}
$sSite.dispose()

Save the PowerShell script to your server.

Create a scheduled task to run the script hourly, daily, weekly, monthly…

Export a list of all sites in a Site Collection

How do you use PowerShell to export a list of all the sites in a Site Collection?


if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$site = Get-SPSite "http://reinmoto.com/customers"

foreach($s in $site.AllWebs)
 {
 Write-Host $s.title
 Add-Content -Path "C:\file.txt" -Value $s.URL
 $s.Dispose()
 }

User Cannot Access a Site

Scenario:

User works in the office for a few weeks, then leaves.

Same user returns a year later.

The user account was never removed from SharePoint, but the user was unable to access sites, where permissions were directly granted.  Sites were Domain Users was implemented, the user could access sites.

On sites where the user was granted direct permissions, they would get the Error: Access Denied message box.

Fix?

Remove the user account and re-add it.

 

 

crawl component cannot be dismounted sharepoint

Was trying to modify the Search Service Topology and ran into a few errors.

Crawl component cannot be dismounted SharePoint

Search Application Topology Status stuck in Recovering

Both errors were cleared up by running the SharePoint Configuration Wizard on the server in question.

Some other errors that occured:

Retry of query component 0e5ab760-3fa2-462f-99a5-aab5c7655dad-query-7 has failed with error: The system cannot find the file specified.
0x80070002. It will be retried again in 64 seconds.

Query component 0e5ab760-3fa2-462f-99a5-aab5c7655dad-query-7 has been taken out of rotation due to this error: The system cannot find the file specified.
0x80070002. It will be retried in 4 seconds.

The parent content type specified by content type identifier 0x01 does not exist

When trying to enable a feature on a site, I was greeted with this following error:

The parent content type specified by content type identifier 0x01 does not exist.

Long story short, the CTYPE feature was not enabled on the site.

Using PowerShell, I exported a list of all the available features in the site.


if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
 Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$web = Get-SPWeb http://yourSharePointsite/
Get-SPFeature | Sort -Property DisplayName > c:\Features.txt

Once exported,  I located the CTYPE feature, grabbed its GUID,  then enabled the feature.


$web = Get-SPWeb http://yourSharePointsite/
Enable-SPFeature "695b6570-a48b-4a8e-9ea5-26ea7fc1d163" -Url $web.Url

Now you should be able to enable the feature that started all this fun.

Who updated the form template?

What to find out who lasted updated a form template?

Scenario:

end user: “My InfoPath form has stopped working!”

me: oh, did anyone make a change to the form?

end user: “umm, not that I know of?!?!”

Inspection Time:

Open the site using SharePoint Designer.

In the left side of Designer, click on All Files.

From there, click on the Library name you are wanting to inspect.

The Library will now be open in your main panel / window.

Open the Form folder.

In there you should see a template.xsn file. *your template might be named something different, but look for the file with a Type of xsn.*

The Modified By column will show you the last user that made any changes to the template.

Case closed!

Hide Button in Ribbon SharePoint 2010

Simple question, how do you hide or remove a button from the ribbon in SharePoint?

In my case, I needed to remove the Upload Document and Open with Explorer buttons for my Form Library.

Open your site using SharePoint Designer.  Once opened, navigate to your Library and edit your default view.  (All Files -> Your Library -> Forms -> Your View.aspx, right click and select Edit File in Advanced Mode)

At the bottom of the screen, you will see three options Design, Split, and Code.  Select the Split option.

In your code window, locate the <asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>  tag.

Now, enter the code below in a line after the PlaceHolderMain tag.

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function () 
{
    setTimeout(HideRibbonButton, 10);  
});
 
function HideRibbonButton()
{
    $('a[id*="OpenWithExplorer"]').hide();   
    $('a[id*="AddDocument"]').hide();     
    setTimeout(HideRibbonButton, 10);
}    
</script>

Click save, then refresh your page.  The Documents tab should now be missing the Upload Document button and the Library tab should be missing the Open with Explorer button.

How I’m finding the items that I want to hide.
using this link:
http://msdn.microsoft.com/en-us/library/ee537543(v=office.14).aspx
Find the item you want to hide (open with explorer).
Ribbon.Library.Actions.OpenWithExplorer

Then use the last part of the string OpenWithExplorer in your jquery.

*NOTE*

The Library I’m working with is locked down and users are not able to create their own Views. If someone creates a new View, the buttons will be available on that page.

No XsltListViewWebPart was found on this page

Received this error when trying to open a page/List from our disaster recover location.

No XsltListViewWebPart was found on this page

Turned out that I didn’t have the 3rd party solution installed.  Make sure you check that your features and solutions are all installed.

*Update*

Had this happen again and ended up finding my own post on Google.

The page / view would not load because of the following reasons:

  • Feature on the site was disabled.
  • The view had a custom web part and some java that referenced the feature.

Fix?

Open the site in SharePoint Designer, navigate to the broken list / library, then edit the view.  *make sure to edit the view in Advanced Mode (look in the ribbon).*

Once you have the view open, look for any web parts or custom code that looks out of place.  In my case, there was an outdated reference in the first line of the code, then a content editor web part that had some inline code.

Once I removed the extra junk, saved my changes, went back to IE and refreshed the page, all was well!

*Update 2*

Received this error when I tried to edit a lookup column.  The column was custom or created by a 3rd party.

To fix the issue, I created a new column, then used PowerShell to copy the contents from BrokenColumn to NewColumn

And then!

Because BrokenColumn was broken, I had to use PowerShell to delete it.

The code below will copy the contents of lookup column to another lookup column.


$cSite = Get-SPweb "http://sharepointed.com/sites/taco"
$cList=$cSite.Lists["Taco List"]

foreach($f in $cList.items)
{
 $uFrom = $f["BrokenColumn"]

 if($uFrom -ne $null)
 {
$f["NewColumn"] = $f["BrokenColumn"]
 $f.Update()
 }
}

This will delete the broken column.


$cSite = Get-SPweb "http://sharepointed.com/sites/taco"
$cList=$cSite.Lists["Taco List"]

foreach($f in $cList.fields)
{
 $fff = $f.Title
 if($fff -eq "BrokenColumn")
 {
$cList.Fields.Delete($fff)
 }
}