Tuesday, March 25, 2014

Getting the GUID of a SharePoint site collection

You can get the GUID by the following ways:
1-   Powershell (SharePoint 2010):
PS > $mysite =  Get-SPSite <SITE_URL>
PS > $mysite.id

2-   Stsadm Command Line (MOSS 2007 & SharePoint 2010):
Stsadm -o enumsites -url <SITE_URL>

3-   SQL Server (MOSS 2007 & SharePoint 2010):
Run the following query on the designated content db:
select SiteId from Webs where webs.FullUrl Like '<SITE_URL>' AND ParentWebId IS NULL

Monday, March 24, 2014

Exporting SharePoint User Profiles to CSV Using Powershell


$siteUrl = "http://YOUR_HOSTNAME_HERE" $outputFile = "c:\temp\sharepoint_user_profiles.csv" Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $serviceContext = Get-SPServiceContext -Site $siteUrl $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext); $profiles = $profileManager.GetEnumerator() $fields = @( "SID", "ADGuid", "AccountName", "FirstName", "LastName", "PreferredName", "WorkPhone", "Office", "Department", "Title", "Manager", "AboutMe", "UserName", "SPS-Skills", "SPS-School", "SPS-Dotted-line", "SPS-Peers", "SPS-Responsibility", "SPS-PastProjects", "SPS-Interests", "SPS-SipAddress", "SPS-HireDate", "SPS-Location", "SPS-TimeZone", "SPS-StatusNotes", "Assistant", "WorkEmail", "SPS-ClaimID", "SPS-ClaimProviderID", "SPS-ClaimProviderType", "CellPhone", "Fax", "HomePhone", "PictureURL" ) erty.IsMultivalued) { $user.$field = $profil
$collection = @() foreach ($profile in $profiles) { $user = "" | select $fields foreach ($field in $fields) { if($profile[$field].Prope[$field] -join "|" } else { $user.$field = $profile[$field].Value } } $collection += $user } $collection | Export-Csv $outputFile -NoTypeInformation $collection | Out-GridView


Reference:

Wednesday, March 19, 2014

Deleting orphaned sites in SharePoint

If you have SharePoint 2007 database attached to SharePoint 2010 Server and you want to to delete some sites from the SharePoint 2007 instance. But when you try to go to "Site Actions > Site Settings" you face "Error , File Not Found"!!
and when you try the PowerShell normal commands, like stsadm -o -deletesite -url <url>  and delete-spsite -url <url> -identity <id> , it says  "Cannot find an SPSite object with Id or Url: xxxx "

You have to follow the right way to delete this sites:

1- Get the database name of the SharePoint 2007 instance: 
Go to the SharePoint 2010 Central Administration>Backup and Restore>Perform a Back Up , and get the database name under SharePoint 2007 web application

2- Get the WebID of the sites: 
In PowerShell use this command; stsadm -o enumallwebs -databasename <SP2007Database> > C:\Allwebs\Allwebs.xml , open the AllWebs.xml and find the url of the site you want to delete and get its ID from the same line.

3-Delete the site:
Use this command; stsadm -o deleteweb -force -webid <SiteID>  -databaseserver <DSName> -databasename <DBName>

Cheers,

Monday, March 17, 2014

Problem while starting a workflow in SharePoint 2013

Sometimes you found that the workflow is not starting, and when you check its status you find "Internal Status: Canceled"


Workflow Canceled










And when you click the blue mark, you will find:

 "System.ApplicationException: HTTP 401 {"Transfer-Encoding":["chunked"],"X-SharePointHealthScore":["0"],"SPClientServiceRequestDuration":["157"],"SPRequestGuid":["eda26c74-95ef-2733-fd4e-518b036ac92b"],"request-id":["eda26c74-95ef-2733-fd4e-518b036ac92b"],"X-FRAME-OPTIONS":["SAMEORIGIN"],"Cache-Control":["max-age=0, private"],"Server":["Microsoft-IIS\/8.0"],"WWW-Authenticate":["NTLM","Basic realm=\"Sharepoint.contoso.com\""],"X-AspNet-Version":["4.0.30319"],"X-Powered-By":["ASP.NET"],"MicrosoftSharePointTeamServices":["15.0.0.4420"],"X-Content-Type-Options":["nosniff"],"X-MS-InvokeApp":["1; RequireReadOnly"],"Date":["Mon, 17 Mar 2014 05:49:27 GMT"]} {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}} at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)



notice that line: "Access denied. You do not have permission to perform this action or access this resource."

--> Before proceeding with solving the problem, make sure that the user initiating the workflow can browse the MySite normally.

then You can try:

  • Site actions > Site Settings > Site features
  • Activate site feature "Workflows can use app permissions"
Or:
  • Make sure that the "User Profile Synchronization Service" is Running.
  • Run a full synchronization in the User Profile Service Application.
Or:
  • Maybe it is a Permissions issue, make sure that the user initiating the workflow has "Edit" or "Contribute" Permission level on the site or the list, and that permission is granted Directly not through an AD group.

References: