Monday, December 17, 2012

Diagnose MissingWebPart and MissingAssembly issues from the SharePoint Health Analyzer using PowerShell

Diagnose MissingWebPart and MissingAssembly issues from the SharePoint Health Analyzer using PowerShell
After posting articles on diagnosing MissingFeature and MissingSetupFile errors in the SharePoint 2010 Health Analyzer and Test-SPContentDatabase operation, I have become slightly obsessed with doing the same for other errors, too. I have also had my fair share of them on migration projects recently, so I can’t be the only one experiencing them at the moment.
In this article I am going to focus on MissingWebPart and MissingAssembly errors. As stated in previous articles, there is no silver bullet to solving these errors in all cases, but the scripts offered here will allow you troubleshoot the errors further to find exactly where they are happening in the content database. Once you know this, you have a fighting chance of being able to solve the problem.
MissingWebPart Error
In this example, I have received the following error whilst running a Test-SPContentDatabase operation after a content database migration from SharePoint 2007 to 2010. It also appears in the SharePoint Health Analyzer under the “Configuration” category with the title “Missing server side dependencies”:
Category : MissingWebPart
Error : True
UpgradeBlocking : False
Message : WebPart class [4575ceaf-0d5e-4174-a3a1-1a623faa919a] is referenced [2] times in the database [SP2010_Content], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy : One or more web parts are referenced in the database [SP2010_Content], but are not installed on the current farm. Please install any feature or solution which contains these web parts.


As you can see, the error gives you a “WebPart class” GUID, the name of the content database, and how many times it is referenced in the database, but little else. What we need to find out here is either the name of the web part or on which pages it is referenced in the database.
For this I am going to reuse the Run-SQLQuery PowerShell script that I introduced in my article on MissingSetupFile errors:
function Run-SQLQuery ($SqlServer, $SqlDatabase, $SqlQuery)
{
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server =" + $SqlServer + "; Database =" + $SqlDatabase + "; Integrated Security = True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$DataSet.Tables[0]
}
Once you have loaded the function in a PowerShell console, you can run it by using the Run-SQLQuery command with the options relevant to your deployment. For [MissingWebPart] errors, you need to run a SQL SELECT query on the “AllDocs” table in the content database exhibiting the problem, joining to the “AllWebParts” table in order to find details about the missing web part. For example, you would type the following command to find details of the web part with the class ID “4575ceaf-0d5e-4174-a3a1-1a623faa919a”, as reported in the error above:
Run-SQLQuery -SqlServer "SQLSERVER" -SqlDatabase "SP2010_Content" -SqlQuery "SELECT * from AllDocs inner join AllWebParts on AllDocs.Id = AllWebParts.tp_PageUrlID where AllWebParts.tp_WebPartTypeID = '4575ceaf-0d5e-4174-a3a1-1a623faa919a'" | select Id, SiteId, DirName, LeafName, WebId, ListId, tp_ZoneID, tp_DisplayName | Format-List
Yes, it is a pretty long command, but it will produce a very useful output, as shown in this example:
Id : 6ab5e70b-60d8-4ddf-93cb-6a93fbc410be
SiteId : 337c5721-5050-46ce-b112-083ac52f7f26
DirName : News/Pages
LeafName : ArticleList.aspx
WebId : dcc93f3e-437a-4fae-acea-bb15d5c4ea7d
ListId : 7e13fe6c-3670-4d46-9601-832e3eb6a1e4
tp_ZoneID : Body
tp_DisplayName :


Id : b3fcfcd2-2f02-4fe9-93e4-9c9b5ecddf5b
SiteId : 337c5721-5050-46ce-b112-083ac52f7f26
DirName : Pages
LeafName : Welcome.aspx
WebId : 2ae0de59-a008-4244-aa66-d8f76c79f1ad
ListId : d8f083f0-16b9-43d0-9aaf-4e9fffecd6cc
tp_ZoneID : RightColumnZone
tp_DisplayName :


This tells us that the web part has been found on two pages (the references mentioned in the MissingWebPart error). SiteId tells us the site collection and WebId the site where the pages are located. We also have a DirName showing the relative path and the page name itself against the LeafName property. If you’re lucky, you might get the display name of the web part against the tp_DisplayName property, but if not, you should at least be able to tell which zone the web part has been added to by looking at the tp_ZoneID property.
Easily the best way of resolving these issues is to do as the error suggests and install the missing feature or solution containing the web part, but if this is not possible or feasible to do in your scenario, we can discover the site collection URL from the GUIDs using PowerShell and then remove the offending web parts from the pages specified. To find the site collection URL using the information output from the query, type the following command:
$site = Get-SPSite -Limit all | where {$_.Id -eq "337c5721-5050-46ce-b112-083ac52f7f26"}
$site.Url
One you have the site collection URL, you can use the relative path specified by the DirName property to find the location of the file. To remove the web part from the page, type the page URL in the browser and add ?contents=1 to the end of it. For example, to open the web part maintenance page for the ArticleList.aspx page specified in the output, type the following URL in the browser:
http://portal/news/pages/articlelist.aspx?contents=1
Note: If you remove an ErrorWebPart from a publishing page with versioning switched on, you may have to delete all earlier versions of the page before the error disappears from the SharePoint Health Analyzer or Test-SPContentDatabase report. This is because the web part will still be referenced from these versions, even though you removed it from the currently published page.

Also note that if you do decide to delete a workflow or a file from the site, remember to remove the file from the site Recycle Bin and Site Collection Recycle Bin to ensure the file is removed from the content database. If not, the error may not disappear from the Health Analyzer.

Thursday, December 6, 2012

SharePoint 2010 pdf not opening

"Unable to Open PDF Directly from SharePoint 2010

After installing SharePoint 2010 your users may find that they can no longer open PDF files and are instead forced to save them to their local machine.

In Internet Explorer 8 Microsoft added a security feature to prevent script injection vulnerabilities caused by buggy client software. This feature is activated by a new HTTP header called X-Download-Options which can be set to noopen. When that header is passed with a file attachment Internet Explorer 8 will not provide the option to directly open the file, instead you must first save the file locally and then open it.

SharePoint 2010 utilizes this enhanced security feature in IE 8 to block the opening of file types it considers vulnerable to scripting or other attacks, such as PDFs. You can modify SharePoint's behavior by changing the Browser File Handling option in the Web Application General Settings of SharePoint 2010. Your options are permissive and strict, with strict being the default.

If your users demand that they open files directly from the web and you are willing to permit the additional security risk you can easily make this modification to your SharePoint web applications."

Friday, November 30, 2012

SP 2010 Access Denied Search Service Application

Getting this error when trying to crawl local content for search:

Error: Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled.

Error:
Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled.
 
Reason:
This error will occur, at the time of crawling the SharePoint application content. because, you may have provided a URL to access the SharePoint web application like http://home.phmic.com (just an example).
When the search engine tried to crawl the content using the home.phmic.com URL, the server will reject the request. because, it will take the request as "LoopBackRequest".
Solution:
So you need to disable the LoopBackRequest in registry. To do this, just follow these instructions:
1. Go to command window and type regedit.exe
2. Once opened the registry editor, just navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa"
3. Right click on "Lsa" and create a new 32bit DWORD value
4. Name it as "DisableLoopbackCheck".
5. Then modify the value of "DisableLoopbackCheck" as "1"
6. Close the registry editor.
7. Now start to crawl the content.

Helpful Links:
http://sensoft2000-sharepoint.blogspot.com/2010/07/error-access-is-denied-verify-that.html
http://wingleungchan.blogspot.com/2011/11/access-is-denied-when-crawling-despite.html

Thursday, November 29, 2012

Add, Remove, Install & Uninstall SP Solution - Powershell

Add-SPSolution C:\PMC\Website.wsp

Add-SPSolution [-LiteralPath] <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Language <UInt32>] [-WhatIf [<SwitchParameter>]]

Remove-SPSolution –Identity Website.wsp

Remove-SPSolution [-Identity] <SPSolutionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-Language <UInt32>] [-WhatIf [<SwitchParameter>]]

Install-SPSolution [-Identity] <SPSolutionPipeBind> [-AllWebApplications <SwitchParameter>] [-AssignmentCollection <SPAssignmentCollection>] [-CASPolicies <SwitchParameter>] [-CompatibilityLevel <String>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-FullTrustBinDeployment <SwitchParameter>] [-GACDeployment <SwitchParameter>] [-Language <UInt32>] [-Local <SwitchParameter>] [-Time <String>] [-WebApplication <SPWebApplicationPipeBind>] [-WhatIf [<SwitchParameter>]]

Uninstall-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-CompatibilityLevel <Int32>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

Thursday, October 25, 2012

Turn off Mobile View for all devices in SharePoint

Go and edit the web.config file of the site (e.g C:\Inetpub\wwwroot\wss\VirtualDirectories\<webapp>)
Add the following code to the configuration/system.web node

<browserCaps>
  <result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  <filter>isMobileDevice=false</filter>
</browserCaps>

Link to Article

Friday, October 19, 2012

Powershell Restore

In SharePoint 2010 you can take a backup of a site collection using the Backup-SPSite cmdlet:
Backup-SPSite http://SPPath C:\Backup\siteCollection.bak [-NoSiteLock]


Restoring a site collection in SharePoint 2010 is just as simple:
Restore-SPSite http://SPPath C:\Backup\siteCollection.bak

Restore-SPSite -Identity <Site collection URL> -Path <Backup file> [-DatabaseServer <Database server name>] [-DatabaseName <Content database name>] [-HostHeader <Host header>] [-Force] [-GradualDelete] [-Verbose]

If you want to restore the site collection to a specific content database, use the DatabaseServer and DatabaseName parameters to specify the content database. If you do not specify a content database, the site collection will be restored to a content database chosen by Microsoft SharePoint Server 2010.

If you are restoring a host-named site collection, use the Identity parameter to specify the URL of the host-named site collection and use the HostHeader parameter to specify the URL of the Web application that will hold the host-named site collection.

If you want to overwrite an existing site collection, use the Force parameter.

Thursday, September 13, 2012

SharePoint Alerts with AD Groups

There are some Security groups in AD that are set up with email settings that will work and there are other ones that don’t have an email tied to them that will not work.

For alerst so to work with AD groups it must have an email address in the email property.  If you add one after it's been synced into SharePoint already you may have to delete group and re-sync in for email address to appear.  Or run SPGroupEMail Powershell command that allows you to manually update email property for an AD group in SharePoint.

More info in this post:
http://sandyulrich.blogspot.com/2012/08/update-user-information-email-in.html

Wednesday, August 29, 2012

Functions in ps1 files

To call a function from a ps1 file you have to have it loaded in the MyFunctions module.

The module can be found here:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\MyFunctions

Add the function in the MyFunctions.psm1 file (have to run Notepad++ as admin in order to edit) or edit the one in C:\Powershell and copy over top.

Then add this line into the ps1 file:
Import-Module MyFunctions

To view all functions in the MyFunctions module run this command in Powershell window:
Get-Command -module MyFunctions




Run ps1 Powershell files

Open SharePoint 2010 Management Shell (run as administrator)

cd \
.\Powershell\NameOfFile.ps1

Put functions in there rather than having to copy paste from txt file.

Currently have ps1 files for:
Updating Photo Store - sync images to SharePoint from AD
Update AD Group Work Email attribute - doesn't sync correctly from AD
Profile Sync - user attributes don't get updated with automatic sync sometimes

Update User Information for an AD Group email in SharePoint...must be set for Group Alerts

If email won't sync in from AD correctly.

Open SP Management Shell (Powershell) and copy and paste:

function Sync-SPGroupEmail([string]$userName, [string]$email) {
  Get-SPSite -Limit All | foreach {
    $web = $_.RootWeb
    if ($_.WebApplication.UseClaimsAuthentication) {
      $claim = New-SPClaimsPrincipal $userName -IdentityType WindowsSamAccountName
      $user = $web | Get-SPUser -Identity $claim -ErrorAction SilentlyContinue
    } else {
      $user = $web | Get-SPUser -Identity $userName -ErrorAction SilentlyContinue
    }
    if ($user -ne $null) {
      $web | Set-SPUser -Identity $user -SyncFromAD
     
      $list = $web.Lists["User Information List"]
      $query = New-Object Microsoft.SharePoint.SPQuery
      $query.Query = "<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>$userName</Value></Eq></Where>"
      foreach ($item in $list.GetItems($query)) {
        $item["EMail"] = $email
        $item.SystemUpdate()
      }
    }
    $web.Dispose()
    $_.Dispose()
  }
}

Or can run function above from C:\Powershell\SPGroupEmail.ps1

cd \
.\Powershell\SPGroupEmail.ps1

Then put in:

Sync-SPGroupEmail "PMC1\group_name" "test@phmic.com"

This Work e-mail must be set for Alerts to be sent to AD groups from SharePoint Lists.



Reference Link

Tuesday, April 24, 2012

Pictures Folder/Heading in Left Nav URL

/Communities/Employee/_layouts/viewlsts.aspx?BaseType=1&ListTemplate=109

Change the Site Logo on Web Part Pages

Question...“How come when we change our site logo for the site collection that it reverts to the default logo on some of our pages?” Well 9 times out of 10, those pages you are referring to are Web Part Pages. Those types of pages have their own logo, and if someone knows the official reason why to this, please say so in the comments. So, in order to keep our site uniform with the logo, then we need to add it here as well:
  • Go to the page that has the offending default logo
  • On the Page ribbon tab, select Title Bar Properties
  • Scroll to the right and on the Web Part Page Title Bar properties paste the URL to your desired site logo
  • Click OK and you’re done!

Friday, April 20, 2012

RSAT for Windows to View AD Users/Groups

Remote Server Administration Tools for Windows 7 with Service Pack 1 (SP1)

Link to Download

Go into Programs/Features and Turn Windows features on or off:

Active Directory Administrative Center (Under Remote Server Admin Tools > Role Admin Tools > AD DS Tools)

Once installed you can do a “start” – “run” – “mmc” and under File menu select the Add/Remove Snap-in... option.   Then add the Active Directory User & Computers snap-in

Friday, April 13, 2012

Run MSI as Administrator

Drop msi file on C driveOpen Cmd Prompt as Administrator
cd ../../
msiexec /i NintexWorkflow2010.msi

Thursday, March 15, 2012

Error when Activating the SharePoint Server Publishing Infrastructure feature

SharePoint Server Publishing Infrastructure:

The error is:

Error

Column Limit Exceeded.

There are too many columns of the specified data type. Please delete some other columns first. Note that some column types like numbers and currency use the same data type.

SOLUTION:
The problem was that sharepoint had somehow multiplied the fields "JobId", "ItemUrl" and "ItemType" so that it was not possible to add those fields in the process of activating the publishing feature. The Solution for me was to delete all those fields from the quick deploy items list since you cannot delete the list itself by default.
http://qaportal/Quick%20Deploy%20Items/AllItems.aspx

Link to Article

Monday, March 12, 2012

Enabling anonymous access in SharePoint 2007

Go to Central Admin:
  • In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs
  • Select “Authentication Providers” in the “Application Security” section
  • Click on the “Default” zone (or whatever zone you want to enable anonymous access for)
  • Under “Anonymous Access” click the check box to enable it and click “Save”
NOTE: Make sure the “Web Application” in the menu at the top right is your portal/site and not the admin site.

Now the second part is to enable anonymous access in the site.
  • Return to your sites home page and navigate to the site settings page. In MOSS, this is under Site ActionsSite SettingsModify All Site Settings. In WSS it’s under Site ActionsSite Settings.
  • Under the “Users and Permissions” section click on “Advanced permissions”
  • On the “Settings” drop down menu (on the toolbar) select “Anonymous Access”
  • Select the option you want anonymous users to have (full access or documents and lists only)
Now users without logging in will get whatever option you allowed them.

Friday, March 9, 2012

Changed Name in AD not syncing with SharePoint

Problem: Profile synchronization was not running between MOSS and WSS for a specific web application.
Solution: Even though the profile imports were running, the SharePoint profiles had a person's old display name instead of their AD display name. The following is from MS support:
1) Stsadm –o sync –listolddatabases 0
2) Stsadm –o sync –deleteolddatabases 0
3) Stsadm –o sync –synctiming m:1
4) Stsadm –o sync –sweeptiming m:1
5) Stsadm –o sync –excludewebapps “”
The last command was the one that reset the profile synchronization so all web apps were again included.

Quick and dirty “User Information List” permissions

In an attempt to make a quick and pretty company contact information list I found that I am very lazy.. well i knew that from the start and it was nothing new to me, but I did find that making the contact information list was a lot easier than I initially tried.
After suffering with creating a SQL View that summarises data from our local AD server using LDAP and reading that data with a BCS and linking it to a list I thought.. Hmmm.. there must a be an easier way..
And there is:
1. Enter User List (assuming you have User Profile Sync working) http://<your_sp_server>/_catalogs/users
You will only be able to access this site if you are logged in as System Admin.
2. Now create your favourite view for your awesome list

Now you got a nice new view, so pretty, check your columns and filters to make sure the users will only see what you want them to see as this list will show all user details including SharePoint groups and everything.
3. Allow your users to see this list. They can’t, well right at this moment at least they can’t. We are going the change that aren’t we, yes we are, such a good SharePoint, who’s a good SharePoint.. oh yes you are, yes you are… Anyway, here comes the trick:
Select your view and open the “Modify this View” option, why did we do this? Because there is no way to edit the list using “List Settings” or using SPD.. so we are going to find the list GUID for this list, the easiest is to copy it from the URL when modifying the view:
http://<your_sp_site>/_layouts/ViewEdit.aspx?List=%7BBA10D037%2D6A45%2D41C0%2D9727%2DE451C0707370%7D&View=%7B6E5E169F%2DC4C1%2D4784%2DB85A%2D8CB1422179A7%7D&Source=xxxxx
Easy isn’t it, now edit your normal “List Settings” URL like this:
http://<your_sp_site>/_layouts/listedit.aspx?List=%7BBA10D037%2D6A45%2D41C0%2D9727%2DE451C0707370%7D
Now when you follow the link and you will get the list settings for the user info list, be careful here, please. I assume you know what you are doing so do not hold me liable for fiddling with stuff you shouldn’t be fiddling with mmkay.
4. Edit permissions to allow Read rights for authenticated users, or similar groups, I am using our “All Users” group from AD, which works like a charm.
Nice isn’t it, this should render you a pretty view for everyone in your AD Sync, so you only need to make sure your AD is up to date, or you can allow users to update their own information using the User Profile Sync services.
Some more reading:
http://www.aiim.org/community/blogs/expert/User-Profile-List-in-SharePoint-2010



Custom Styles for SharePoint 2010 Rich Html Field

A typical requirement from a client is to be able to incorporate their own custom styles for the Rich Html Field. Allowing their public relations department to apply nice text formating for paragraphs with some Comic Sans Hotness might not be the best practice in here, so let’s be careful out there. The best scenario is only to allow custom formatting for headings, paragraphs and maybe a few different table styles but let’s go!
First, open up the page layout containing the HTML editor and add PrefixStyleSheet property for the RichHtmlField:
<PublishingWebControls:RichHtmlField
    id="Content"
    FieldName="PublishingPageContent"
    PrefixStyleSheet="my-rte"
    runat="server"
/>
Now, the default value for the property is ms-rte. We are going to redefine this to my-rte. Do not use any uppercase characters in the property value as apparently those wont work. Deploy the page and open it in edit mode to see the desired effect. The styles collections are now empty in the Ribbon.
We now have to define our own styles prefixed with the string my-rte. I’d suggest that you put these style declarations in a separate stylesheet to avoid javascript errors caused by complicated and hard-to-parse stylesheets. Let’s name our new stylesheet rte.css and add a few declarations there.

The Markup Collection

Let’s say I want to have an option to add a level 1 heading or an H1 tag for the given page via the Markup Styles dropdown list:
Step 1 – introduce the tag:
H1.my-rteElement-H1
{
  -ms-name:"my level 1 heading";
}
Step 2 – add the styles to the tag:
.my-rteElement-H1
{
    font-size: 150%;
}
Save the rte.css and make a reference for it in your master page, page layout or even use an alernative css. If you want your clients to be able to edit the styles themself, you could upload the rte.css in the Style Library and reference it there.
I have saved the file directly in the 14-hive /_layouts/my/ -folder and use a quick reference in the master page:
<SharePoint:CssRegistration
    ID="CssRegistration1"
    runat="server"
    Name="/_layouts/my/rte.css"
/>
Deploy and reload the page, fire up the edit mode and navigate to the ribbon where you can see your new style in action.


Adding new elements is easy once you get to know the logic. Here’s an example of a parapgraph with nice rounded corners and superb font on modern browsers (note that I have combined the introduction and style values in one declaration):
P.my-rteElement-P
{
    -ms-name:"My CSS Rounded Paragraph";
    background: #808;
    color: #fff;
    border: 3px solid #f0f;
    text-transform: uppercase;
    text-align: center;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    box-shadow: 0 0 20px #000;
    -moz-box-shadow: 0 0 20px #000;
    -webkit-box-shadow: 0 0 20px #000;
    padding: 10px;
    font: bold 2em Comic Sans MS;
}

The Styles Collection

The Styles collection can be populated with the same way by changing the Element-suffix into Style ie.:
.my-rteStyle-MePinky
{
  -ms-name:"I am pink";
  color: #f0f;
}

Friday, February 17, 2012

SharePoint Designer wrongfully says a file is checked out when it is not

Ran into a new problem with SharePoint Designer today. Not sure how I caused this to happen but several files were marked as checked out in SPD despite the fact that the files were not checked out to anyone in SharePoint. SPD would not allow me to check out the files, errored if I tried to check in the files, restarting SPD didn’t help, even rebooting didn’t help.

Turns out you have to clear a cache in the local app storage. The fix to this problem is to navigate to your local app settings WebSiteCache folder, which in Windows 7 is here:

C:\Users\Randy\AppData\Local\Microsoft\WebsiteCache

From there just delete all the files or just the ones that correspond to your SharePoint site. When you restart SPD you may have to check in/out the files one more time, but after the warning message the file status will return to normal.

Link to Article

Monday, January 30, 2012

Powershell Delete Unused WF Column

This script works as a function – meaning that there are two parts to running it in the SharePoint 2010 Management Shell. First, you have to run the script shown below:
function Delete-WorkflowColumn ($webURL, $listName, $columnName)
{
    #Setup variables from the user input
    $web = Get-SPWeb $webURL
    $list = $web.Lists[$listName]
    $column = $list.Fields[$columnName]
   
    #Make sure the column is not hidden or read only
    $column.Hidden = $false
    $column.ReadOnlyField = $false
    $column.Update()

    #Delete column and dispose of the web object
    $list.Fields.Delete($column)
    write-host "Deleted column"
    $web.Dispose()
}


Once the function has been run, you can call it to actually remove a column with the following command:
Delete-WorkflowColumn -webURL http://portal -listName "Documents" -columnName "Approval Workflow"

The example above deletes the “Approval Workflow” column from all list views of a document library called “Documents” in the site http://portal/.

Whilst I have focused in this article on removing columns generated by unused workflows, you can use exactly the same script to remove columns from any list or document library.

Wednesday, January 25, 2012

Tuesday, January 24, 2012

Stsadm Commands

Export/Import

stsadm.exe -o export -url http://localhost/ -filename C:\Export.cab -includeusersecurity -versions 4 -overwrite
stsadm.exe -o import -url http://localhost/ -filename C:\Export.cab -includeusersecurity

Can export/import sub-sites with this method (i.e. http://portal/Communities/Employee)

http://technet.microsoft.com/en-us/library/cc288191(office.12).aspx

Backup/Restore

stsadm -o backup -url http://localhost/ -filename c:\helpdesk.bak
stsadm -o restore -url http://localhost/ -filename c:\helpdesk.bak -overwrite

http://technet.microsoft.com/en-us/library/cc263431(office.12).aspx

Wednesday, January 18, 2012

PowerShell Commands To List SharePoint Features

List all installed features on the farmIt’s really straight forward using the Get-SPFeature command to return all installed features. To provide a little more readability to the output it can be sorted as follows:
By feature display name alphabetically,

Get-SPFeature | Sort -Property DisplayName

By feature ID,

Get-SPFeature | Sort -Property Id

By feature display name alphabetically and grouped by scope,

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id

And to write this to a file to allow for viewing in Notepad, Excel etc,

Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id > c:\AllInstalledFeatures.txt

List all activated site scoped featuresEspecially in the case of hidden features it’s sometimes necessary to track down if a feature is active on a site collection. Here’s a quick way of seeing which features are activated for an SPSite:

Get-SPFeature -Site http://sitecollectionurl | Sort DisplayName | FT DisplayName,Id

List all activated web scoped featuresAnd only slightly modified from the Get-Help Get-SPFeature -examples text, here is a command to list all web activated featres for a site collection:

Get-SPSite http://sitecollectionurl | Get-SPWeb -Limit ALL | %{ Get-SPFeature -Web $_ } | Sort DisplayName -Unique | FT DisplayName,Id

From this site: Link to Site

Thursday, January 12, 2012

Uninstall ReportServer Feature in SP 2010

After upgrading to SharePoint 2010 I have these Site Content Types now in my site collection.  To get rid of them you have to uninstall the Report Server feature and re-install.

To do this in PowerShell:
Uninstall-SPFeature ReportServer -force
Install-SPFeature ReportServer

Go into Site Collection Features and activate Report Server Integration feature (and then deactivate if you don't need it).

Tuesday, January 10, 2012

Nintex URLs

Custom Start Page:
_layouts/NintexWorkflow/PHMIC_Custom/CustomStartWorkflow.aspx

Locate all Nintex flows in Site:
/NintexWorkflows/Forms/AllItems.aspx