Archive

Author Archive

#ProjectServer 2013 environment migration / rollover steps #PowerShell #PS2013 #MSProject #SP2013

Paul Mather
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011.
I am also a certified Prince2 Practitioner.

This article has been cross posted from pwmather.wordpress.com (original article)

This blog post will detail the PowerShell commands required to carry out an environment rollover / migration using Windows PowerShell where possible. The steps below use the 2 database approach to rollover over the Production environment to the Test / Development environment.

As a prerequisite I would recommend taking full backups of the Test / Dev farm to enable the environment to be rolled back if required. Use your usual farm backup procedures.

Test / Dev environment Prep

Firstly connect to the Test / Dev Application server and launch the SharePoint 2013 Management shell.

Type the following:

Dismount-SPProjectWebInstance -SiteCollection  <URL of Test / Dev PWA site that you want to refresh with the Production data and config>

Example:

image

Press Enter and then type Y and press Enter to remove the PWA instance

image

You can check in Central admin in the Project Server Service Application to check that the PWA site has been removed:

image

Using the SharePoint 2013 Management Shell remove the existing content database from the web application that hosted the PWA site collection that was removed in the previous step.

Type the following:

Dismount-SPContentDatabase “<Database name here>”

Example:

image

Press Enter and type Y to confirm then press Enter

image

Test / Dev environment SQL Prep

Take a backup of the 2 databases from the Production environment and copy these over to the Test / Dev SQL server and restore the databases. The databases required are:

  • Content database that contains the PWA site and Project Sites
  • Project Web App database

Make a note of the database names used when these databases are restored as they will be required later.

Test / Dev environment configuration

Using the SharePoint Management Shell, attach the restored content database to the web application that will host the PWA site collection.

Type the following:

Mount-SPContentDatabase “<content database name restored in previous step>” -DatabaseServer “<Test / DEV SQL Server>” –WebApplication <web application URL>

Example:

image

Press Enter:

image

Using the SharePoint 2013 Management Shell mount the restored Project Web App database to the web application.

Type the following command:

Mount-SPProjectDatabase -Name “Name of the restored Project Web App database to mount” –WebApplication “Web Application ULR that the Project Web App database will mount to” –DatabaseServer “Test / Dev SQL Server where the database was restored

Example:

image

Press Enter:

image

Now using the SharePoint 2013 Management Shell provision the PWA site collection in the web application where the database was just attached to and using the Project Web App database that was restored previously. Please note, use the same PWA path name used in Production. For example if the instance is called /PWA in Production, use /PWA in the command below on the Test / Dev environment.

Type the following command:

Mount-SPProjectWebInstance –DatabaseName “Name of the restored Project Web App database to mount” –SiteCollection “web application URL + PWA path” –DatabaseServer “Test / Dev SQL Server where the database was restored

Example:

image

Press Enter:

image

You can check the provisioning status of the PWA site using PowerShell or in Central admin in the Project Server Service Application to check that the PWA site has been created:

Type the following:

Get-SPProjectWebInstance –URL <PWA URL> | Select ProvisioningStatus

Example:

image

Or in Central Admin:

image

Post Provisioning

The Project Sites will need to be relinked using the “Bulk Update Connected SharePoint Sites” functionality in Central Admin on the newly provisioned Test / Dev PWA site.

The Project Server Cube settings will need to be updated – update the SQL AS server / cube name.

Any Excel services reports will need to be updated to use the ODC files from the Test / Dev environment as they will currently point to the Production ODC files. This is done by opening the Excel reports in Excel, changing the ODC file then saving the file back to the library.

Categories: Paul Mather, Work Tags:

Update #SharePoint list item author and editor #SP2010 #PowerShell #PS2010 #SSRS

Paul Mather
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011.
I am also a certified Prince2 Practitioner.

This article has been cross posted from pwmather.wordpress.com (original article)

Recently while working on a client deployment we had an issue relinking the SSRS reports to the data sources within the same library – SSRS was in SharePoint integrated mode. We had developed the Project Server solution internally and migrated it to the clients environment at a later date. All worked as expected apart from trying to relink the SSRS Reports to the updated data sources. The SSRS data sources had been edited to use the correct databases / PSI web services but when we tried to link the reports to the databases from the Manage Data Sources menu, SharePoint threw an error when trying to browse to the data sources. The error from the ULS log can be seen below:

Microsoft.ReportingServices.Diagnostics.Utilities.SharePointException: , Microsoft.ReportingServices.Diagnostics.Utilities.SharePointException: Report Server has encountered a SharePoint error. —> System.NullReferenceException: Object reference not set to an instance of an object.  
at Microsoft.ReportingServices.SharePoint.Objects.RSSPImpUser.get_LoginName()  
at Microsoft.ReportingServices.SharePoint.Utilities.CatalogItemUtilities.GetListItemUserLoginName(RSSPListItem item, String fieldName)

The cause of this error was that the user who created the SSRS objects had been removed from SharePoint when the system was cleaned up to take on to the clients environment.

There is a simple fix, that is to update the Author (Created By) and Editor (Modified By) fields with a user that exists on the SharePoint farm. The Author field can’t be updated via the UI but it can be update via the object model.

I created a simple PowerShell script that will update the author and editor for all SharePoint list items in the chosen list. To download the PowerShell script please see the link below:

http://gallery.technet.microsoft.com/scriptcenter/Update-SharePoint-list-4e6272ab

There are some variables / settings that need to be updated before running the script, these can be found below:

$newuser = "support\paulmather"  This needs to be updated with the new author and editor’s user account.

$site = get-SPWeb http://vm353/pwa/ProjectBICenter This needs to be updated with the correct URL for the site that contains the list / library.

$list = $site.Lists["Test"] This needs to be updated with the name of the correct library / lists that contains the list items that need to be updated, in this example the SSRS items.

That is it, the script is then ready to run.

Please fully test on a replica test farm before running on Production.

Categories: Paul Mather, Work Tags:

#ProjectServer 2013 PWA more integrated with Project Sites #PS2013 #SP2013

A quick post to express my pleasant experience of finding that Project Sites in Project Server 2013 are more integrated with PWA then ever before 🙂

Since long i have been vocal about the distant connection between Project sites and PWA, formerly known as Project Work spaces in PS2007. Although project sites are meant to be a second home, other then PWA, to project team for their project activities.

However this distance some how comes in a way while convincing users to use project site associated with project to manage artifacts such as documents, issues and etc. One of the common request received in this case was, how to show projects tasks or project status on project site? and since there is no OOB way of achieving this in PS2010, then you have to come up with all these brilliant ideas of developing different custom solutions to accommodate such requests.

But it comes as a pleasant surprise in PS2013 that Project Sites are now more seamlessly connected with PWA. Though still the distant feeling exist, but was overcome to some extent to give user a more connected feel of Project site with their projects.

Your first experience: Project site link do not exist on ribbon anymore, its from with the Project now.

 click on Project Name, and you will see the Project Site link along with PDPs.


 click on Project Site link, and it will NOT open in separate window as new site like old times: (unless you prefer, and use any of the trick to open in new window 🙂  )

(some whistles.. please 🙂 )

my first impression was WOW, the home page by-default shows the status including Project Timeline and Alert alert that you are behind schedule.


Deliverable/Issues and Risks lists are the same, in fact Paul Mather few days back wrote about the change of functionality of linking tasks along with issues/risks and documents here and took the opportunity away from me since i was also planning to write the same 🙂

(ok, ready for more good things …. :), here you go )

Tasks link until PS2010 was of no good in most cases, in fact i used to rename it as “Team Tasks OR Personal Tasks” for customers to avoid the confusion of mixing these tasks as project schedule tasks.

But now these alternates are not required any more. Lets click on Tasks link: 

Your project tasks are displayed here to be shared with team, and of course you can change the view of tasks page to show you only Yours Tasks or etc. However you cannot edit the values of tasks here, such as %complete, it will take you back to project schedule for the editing which i believe is pretty logical.

Before we wind up, a quick hint to show that you can also add a famous Timeline web-part  to your project site home page to show timeline alone. And also you can modify the existing Project Summary web-part to reflect information minus timeline.

Here you go:

And now last but not the least, in order to go back to PWA, no need to look for navigation link on project site. Simply click on Project Details link to access project details:

Fig-1


This is it for now, we have seen enough good things – now lets get back to the real work issues 🙂

via All about Enterprise Project Management (EPM) http://khurramjamshed.blogspot.com/2013/05/projectserver-2013-pwa-more-integrated.html

Khurram Jamshed
The author of the blog has an extensive experience of working as an EPM Consultant. Currently he is located in Dubai, UAE and working for Microsoft partner organization as Project Server specialist. He has a thorough experience of providing Project Management technical/functional consultancy to all sort of organizations. He is a certified PMP, a Project Server MCITP, and also received a MS community contributor award 2011.

This article has been cross posted from khurramjamshed.blogspot.com/ (original article)

Dr Popup: Or How I learned to stop worrying and love the modal dialog

April 25, 2013 Leave a comment

One of the many pieces of functionality added in SharePoint 2010 was the dialog window, this is a nice little control implemented in JavaScript that allows us to display a “lightbox” style dialog, containing either another page within our site or direct HTML.

This post will explain how to pass information back and forth between the page creating the dialog and the page displayed within that dialog.

Firstly lets take a look at the JavaScript on our calling page. This could be added through any of the normal methods of inserting JavaScript into a SharePoint page.

(function() {

	// Use jQuery to wait for the DOM to be ready
	$(document).ready(function(){

		// Use SharePoint's SOD (script on demand) to wait for SharePoint to be ready
		ExecuteOrDelayUntilScriptLoaded(function() {

			//Create an options object (valid options properties reference - http://msdn.microsoft.com/en-us/library/ff410058(v=office.14).aspx):
			var options = SP.UI.$create_DialogOptions();

			options.title = "My dialog";
			options.autoSize = true;
			options.url = "/pages/myPage.aspx";

			//arguments to pass in to dialog (standard anonymous object)

			options.args = {
				someKey: "Some Value",
				someOtherKey: "Some Other Value"
			}

			//callback to handle the result from the dialog, you process the result of your
			//dialog from the origin page.

			options.dialogReturnValueCallback = function(result, arguments) {
				if (result == SP.UI.DialogResult.OK) {

					// Our arguments parameter contains the arguments originally passed to the dialog, so we could
					// reference arguments.someOtherKey here for instance and it would contain the value "Some Other Value"

					SP.UI.Notify.addNotification("OK Button clicked");

				} else if (result == SP.UI.DialogResult.Cancel) {

					SP.UI.Notify.addNotification("Cancel button clicked");

				}
			}

			// Create the dialog with options.
			SP.UI.ModalDialog.showModalDialog(options);

		}, "SP.UI.Dialog.js");

	});

})();

As you can see, there are 3 major parts to this, the options object, the args object and the callback.

The options object is created using the SP.UI.$create_DialogOptions() factory, although I have seen people using an empty object without apparent issue.

Into this you set various options affecting the way the dialog is presented, such as title, size and the url to the page to be displayed. A list of available options is posted on MSDN.

The args object is actually a property of the options object, and can be any sort of JavaScript object, be it an anonymous object like in our example above, or a closure, or a data model or anything else you may wish to send. This object will be available within the page shown in your dialog.

The last part is the callback, this is also a property set against the options object, and is a callback method executed when the DialogClose() method is called from within the parent page.

It takes two parameters, the result which should be one of the members of the SP.UI.DialogResult enumeration and the arguments, which can be any kind of variable or object returned from the dialog page.

Additionally in here you can call SP.UI.ModalDialog.RefreshPage() – this method takes a single parameter and is designed to be called using the result value from your callback. This method ensures that the page refreshes if the result is equal to SP.UI.DialogResult.OK

With these three sections we can define how our dialog looks, what data it takes in, and what happens once it is closed and how to process the data that comes back from it.

Lastly the dialog itself is opened using the call to SP.UI.ModalDialog.showModalDialog()

Now lets take a look at the other side of the coin, here’s the JavaScript code to run within the dialog page.

(function() {

	// As on the parent page, wait for the DOM and SharePoint to be ready before doing anything.
	$(document).ready(function() {
		ExecuteOrDelayUntilScriptLoaded(function() {

			// retrieve a reference to the page that called us.

			var _parent = SP.UI.ModalDialog.get_childDialog();

			// If this is false, then chances are you have browsed to the page directly rather than
			// loaded it in a modal window.
			if (_parent) {

				// Pull through the arguments sent to the dialog.
				var args = _parent.get_args();

				// set a red alert status line with our argument.
				var status = SP.UI.Status.addStatus("someKey:", args.someKey);
				SP.UI.Status.setStatusPriColor(status, "red");
				
				// Add handlers for our ok and cancel buttons
				$("#okButton").click(function() {
					// This closes the modal dialog and runs the callback method defined on the parent page.
					SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, args);
				});

				$("#cancelButton").click(function() {
					SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel, "cancel clicked");
				});

			}

		}, "SP.UI.Dialog.js");
	});
})();

This again is fairly simple, we first of all get a reference to the calling page in the variable _parent. Then if that has been successful we pull in the args object from our options variable above.

Once at this point the world is your oyster, you can use the arguments from the parent page however you wish to display the dialog or interact with your users.

To close the dialog you can use SP.UI.ModalDialog.commonModalDialogClose(). This again takes two parameters, the first should be a member of the SP.UI.DialogResult enumeration, the second can be any object to send back, these map to the variables sent to our callback function above.

Additionally in here I have made use of some of the other neat parts of the SP.UI namespace such as the status bar and notification system. These are beyond the scope of this post but they’re pretty awesome and you should go read about them.

So there we go, by now you should be able to add true SharePoint style dialogs to your pages with minimal effort.

via Chris on SharePoint http://spchris.com/2013/04/dr-popup-or-how-i-learned-to-stop-worrying-and-love-the-modal-dialog/

Chris Stretton
SharePoint and Project Server Consultant

  • MCITP – SharePoint Administrator 2010
  • MCTS – Microsoft Project 2010 – Managing Projects, Project Server 2010, Configuration, SharePoint 2010, Configuration
  • Prince 2 – Practitioner

This article has been cross posted from spchris.com (original article)

Where is the Project Fields web part in #ProjectServer 2013? #PS2013 #SP2013

April 25, 2013 Leave a comment
Paul Mather
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011.
I am also a certified Prince2 Practitioner.

This article has been cross posted from pwmather.wordpress.com (original article)

A quick post to highlight a minor change to the PWA web parts in 2013. I was in the process of creating a new PDP on a 2013 environment and I wanted to add certain custom fields. In 2010 the web part that enabled you to do this was the Project Fields web part:

image

In 2013 this web part doesn’t exist, well it does but it is no longer called Project Fields, it is now called Basic Info:

image

It provides exactly the same functionality as the Project Fields web part in 2010.

Hopefully that will save you hunting around for this web part Smile

Categories: Paul Mather, Work Tags:

#ProjectServer 2013 linking list items to tasks and other list items #PS2013 #SP2013

April 24, 2013 Leave a comment
Paul Mather
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011.
I am also a certified Prince2 Practitioner.

This article has been cross posted from pwmather.wordpress.com (original article)

The linking functionality has changed in Project Server 2013, in Project Server 2010 you used to create the links on the Custom Commands tab as shown below:

image

In 2013 this feature has been updated and no longer exists on the new or edit forms. This blog post covers how you can links items in 2013 using the web interface.

Firstly we will look at how you do this from one of the lists, in this example we will use the Issues list. As you can see in the image below, I have 2 issues:

image

To link Issue 1 to a task in the project, click Issue 1 and you will see the following page:

image

Click Add Related Item:

image

Double click Tasks:

image

Select the task required and click Insert:

image

Issue 1 will now show task T1 as the related item:

image

Clicking T1 will load the display form for T1 and show Issue 1 as the related item:

image

The project schedule in PWA will show the Issue icon that links to the Issue (same as 2010):

image

It is the same process described above to link Issues to Risks or Risks to Issues etc.

The second method to link tasks to issues is from the Tasks list on the project site:

image

Click one of the tasks:

image

Click Show More:

image

Click Add Related Item and follow the same steps above to select the related item.

The third method is from the schedule page in PWA. Select the task from the grid and click the Options tab:

image

Click the Related Items button on the ribbon and that task will open from the task list on the project site:

image

Notice this time the Related Items is displaying by default. This is due to &ShowRelatedItems=1 being appended to the URL. Now follow the same steps detailed above to select the related item.

Slightly more steps to link items but very simple.

Categories: Paul Mather, Work Tags:

Switch to #ProjectServer #Permission mode from #SharePoint permission mode

April 24, 2013 Leave a comment
Challenging part while using new version of any product is to find new location of features/options within new version, if they are no longer available on the same spot as of their former version.

This post will help you to find key feature of Project Server 2013, Security Settings in Project Server 2013, that used to be under server settings of Project Server 2010.

With the introduction to new security mode in Project Server 2013, i.e. :SharePoint Permission mode, your new PWA by default will provision with SharePoint permission mode and hence you will find Security section missing from PWA server settings page.

Advantages, and what is enabled and what is not, while staying with SharePoint security mode are detailed here: http://technet.microsoft.com/en-us/library/fp161361.aspx

Out of the above article, and with R&D i have done so far, the major features you were not be able to use in SharePoint security mode are as follows:

  • Unable to edit default permission of groups
  • RBS
  • categories
  • Delegation
As you are aware that permissions in PS 2010 and PS 2007 was the combination of security groups, categories and RBS. SharePoint security mode helps get rid of this complexity and provide single forum for system admins, i.e. SharePoint groups, to configure permission for PWA as well. 

SharePoint Permission Mode creates SharePoint groups that directly correspond to the default security groups found in Project Permission Mode. These default security groups include the following:
  • Administrator
  • Portfolio Managers
  • Portfolio Viewers
  • Project Managers
  • Resource Managers
  • Team Leads
  • Team Members
I have modified the quick launch in above screen shot to show you all the relevant groups, however you can click on Groups link on the top to access to full list of groups. 
Using of SharePoint security could be beneficial for naive organizations or to those who are willing to run project management business without creating data access layers based on user role defined through RBS. There could be several more reasons of using PWA in SharePoint security mode as well.
The recommended way of adding user to group is still the Active Directory synchronization, available through server settings.

In order to switch the permission mode back to Project mode, use the following windows powershell cmdlet:

Set-SPProjectPermissionMode [-Url] <Uri> [-Mode] <SharePoint | ProjectServer | UninitializedSharePoint | UninitializedProjectServer> [[-AdministratorAccount] <String>] [-AssignmentCollection <SPAssignmentCollection>]

For detail of above cmdlet, see this technet article:: http://technet.microsoft.com/en-us/library/jj219486.aspx

Once the prompt will be back after execution, refresh the PWA server settings page to see the Security group available to be used.

Note that Switching security modes deletes all permissions configuration information for the specified Project Web App instance and reverts to the default settings for the specified mode. You need to be carefully planning this well in advance that which security mode you have to configure.

via All about Enterprise Project Management (EPM) http://khurramjamshed.blogspot.com/2013/04/switch-to-projectserver-permission-mode.html

Khurram Jamshed
The author of the blog has an extensive experience of working as an EPM Consultant. Currently he is located in Dubai, UAE and working for Microsoft partner organization as Project Server specialist. He has a thorough experience of providing Project Management technical/functional consultancy to all sort of organizations. He is a certified PMP, a Project Server MCITP, and also received a MS community contributor award 2011.

This article has been cross posted from khurramjamshed.blogspot.com/ (original article)

Collection of #Powershell Scripts for Sharepoint #ContentType #CTHub #Sites #Lists

April 23, 2013 Leave a comment

In my current client project I had to design a Sharepoint portal with many lists and libraries that will eventually be re-usable across the organisation (ie the same lists structure will be used by several sites, sub-sites under several site collections and potentially in separate web applications), therefore using the SharePoint Content Type Hub was the obvious built-in solution to keep the Content Types centrally managed. However you will find out that using the browser to perform the tasks to edit the content types and publish them to all sites can become a major time consuming and if like me you don’t like to click twice to achieve the same thing, the need to automate those edits is paramount. Powershell to the rescue, here are the main scripts I use for manipulating Content Types, pushing them, but also others such as create new web application, new site collection, managed path, content type and more.

(click each “expand source” section to grab the scripts)
  • Add Sharepoint Snap-In to Powershell
(the basis if using PowerGui, which I definitely recommend, thanks Paul  for recommending it to me, this tool totally changed my opinion on Powershell)
Add-PsSnapin Microsoft.SharePoint.PowerShell
 [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint')
  • Activate Taxonomy feature option under Site Collection Administration
 (to receive Content Type Hub Published content types, missing from Blank Template)
# Activate Content TypeHub option under Site Collection Administration
stsadm -o activatefeature -id 73EF14B1-13A9-416b-A9B5-ECECA2B0604C -url http://MySharePointSrv.com/sites/sitecol1
  • Unpublish All Content Types containing Custom Group Name

$HubUrl = “http://cthub.MySharePointSrv.com”
$HubSite = Get-SPSite $HubUrl
$HubWeb = $HubSite.RootWeb
$Publisher = New-Object Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher($HubSite)
$ContentTypes = $HubWeb.ContentTypes
foreach ($ContentType in $ContentTypes)
{
        $contentTypeGroup = $ContentType.Group
        $contentTypeName = $ContentType.Name

		# only publish the nMySharePointSrv Conten Types
		if ( $contentTypeGroup  -like '*MyCustomGroupName*')
		{
			 $Publisher.Unpublish($ContentType)
             echo &quot;UNPUBLISHED [CONTENT TYPE GROUP] $contentTypeGroup, $contentTypeName&quot;
		}
 }
$HubSite.Dispose()
  • (re)Publish All Content Types containing Custom Group Name to Subscribing web application

$HubUrl = “http://cthub.MySharePointSrv.com”
$HubSite = Get-SPSite $HubUrl
$HubWeb = $HubSite.RootWeb
$Publisher = New-Object Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher($HubSite)
$ContentTypes = $HubWeb.ContentTypes
foreach ($ContentType in $ContentTypes)
{
        $contentTypeGroup = $ContentType.Group
        $contentTypeName = $ContentType.Name

		# only publish the nMySharePointSrv Conten Types
		if ( $contentTypeGroup  -like '*MyCustomGroupName*')
		{
			 $Publisher.Publish($ContentType)
             echo &quot;PUBLISHED [CONTENT TYPE GROUP] $contentTypeGroup, $contentTypeName&quot;
		}

    }

$HubSite.Dispose()
  • Force the Publish content types from Content Type Hub to a target web application (instead of waiting for job to start on schedule
# http://get-spscripts.com
#Run the Content Type Hub timer job
$ctHubTJ = Get-SPTimerJob &quot;MetadataHubTimerJob&quot;
$ctHubTJ.RunNow()

#Run the Content Type Subscriber timer job for a specific Web Application
$ctSubTJ = Get-SPTimerJob &quot;MetadataSubscriberTimerJob&quot; -WebApplication http://MySharePointSrv.com
$ctSubTJ.RunNow()
 echo &quot;Metadata Hub Job initiated&quot;

  • Read a text file that lists some files to be used as Content Types, iterates through each files and its create contents

The IMPORTFILES.TXT has this format

doc1 – Document title1.dotx
doc2 – Document title2.dotx
doc3 – Document title3.dotx
&lt;# Create Content Type
#http://jaclynsaito.wordpress.com/2011/06/07/create-a-sharepoint-2010-content-type-using-powershell/
#&gt;
# Set Variables
$url = &quot;http://cthub.MySharePointSrv.com&quot;
$cGroup = &quot;MyContentTypes Group&quot;
# Read list of document template to create CT
$DocumentTemplatesArray = Get-Content &quot;C:\temp\IMPORTFILES.txt&quot;
$CTHubSiteColl =  &quot;http://cthub.MySharePointSrv.com&quot;

$site = get-spsite $url

$web = $site.openweb()

$ctypeParent = $web.availablecontenttypes[&quot;Document&quot;]

 # Loop thru the number of CT to create
$i = 0
$MaxCT = $DocumentTemplatesArray.count  # total CT to create
 write-host &quot;--------&quot; + $DocumentTemplatesArray.count total lines read from file + &quot;-------&quot;+
foreach ($line in $DocumentTemplatesArray)
{
    $templateURL = &quot;/DocumentTemplates/&quot; + $ctypeName   # URL of templatefile with extension
    $ctypeName = $line.replace(&quot;.doc&quot;,&quot;&quot;).replace(&quot;.xls&quot;,&quot;&quot;).replace(&quot;.vst&quot;,&quot;&quot;).replace(&quot;.xltx&quot;,&quot;&quot;)   #name of CT without extension

    Write-Host $i + &quot;: &quot; + $ctypeName

    $ctype = new-object Microsoft.SharePoint.SPContentType($ctypeParent, $web.contenttypes, $ctypeName)

    $web.contenttypes.add($ctype)

    # ADD CUSTOM COLUMN
     $web.fields.add(“myField”, ([Type]“Microsoft.SharePoint.SPFieldType”)::Text, $false)
     $field = $web.fields.getfield(“myField”)
     $fieldLink = new-object Microsoft.SharePoint.SPFieldLink($field)
     $ctype.fieldlinks.add($fieldLink)

    #   set the current document template file to be the document tmeplate
    $ctype.DocumentTemplate = $templateURL
    $ctype.Group = $cGroup  # give GroupName

    &lt;# Publish Content Type  #http://www.jeffholliday.com/2011/08/powershell-script-create-content-type.html #&gt;#
    write-Host &quot;---- now publish to : &quot; + $CTHubSiteColl
    $Publisher = New-Object Microsoft.SharePoint.Taxonomy.ContentTypeSync.ContentTypePublisher($CTHubSiteColl)

    $Publisher.Publish($ctype);

    #   update the content type
    $ctype.Update()
     $i++
 }

 # END OF LOOP TO CREATE CT
$web.Dispose()
$site.Dispose()
  • Create a new Web Application
# Declare  Variables
$siteName = “SP - MyWebApp.sharepoint.com”
 $port = 80
 $hostHeader = “MyWebApp.sharepoint.com”
 $path = “d:\dedicateddrive\MyWebApp.sharepoint.com”
 $url = “http://MyWebApp.sharepoint.com:80”
 $appPoolName = “SP - MyWebApp.sharepoint.com”
 $managedAccount = “sharepoint\Sharepoint-WebApp-MA”
 $dbServer = “Sharepoint-SQL”
 $dbName = “Sharepoint-MyWebApp”
 $allowAnonymous = $false
 $authenticationMethod = “NTLM”
 $ssl = $false
#Create the Web app
New-SPWebApplication -Name $siteName -Port $port -HostHeader $hostHeader -Path $Path -URL $url -ApplicationPool $appPoolName -ApplicationPoolAccount (Get-SPManagedAccount “$managedAccount”) -DatabaseName $dbName -DatabaseServer $dbServer -AllowAnonymousAccess: $allowAnonymous -AuthenticationMethod $authenticationMethod -SecureSocketsLayer:$ssl
&lt;/div&gt;
  • Convert existing Web Application from classic-mode to claims-based authentication 
 # http://technet.microsoft.com/en-us/library/gg251985(v=office.14).aspx

#set the specified user account as an administrator for the site
$WebAppName = &quot;http://MySharePointSrv.com&quot;
$wa = get-SPWebApplication $WebAppName
$wa.UseClaimsAuthentication = $true
$wa.Update()

#configure the policy to enable the user to have full access
$account = &quot;MySharePointSrv\SPSetup&quot;
$account = (New-SPClaimsPrincipal -identity $account -identitytype 1).ToEncodedString()
$wa = get-SPWebApplication $WebAppName
$zp = $wa.ZonePolicies(&quot;Default&quot;)
$p = $zp.Add($account,&quot;PSPolicy&quot;)
$fc=$wa.PolicyRoles.GetSpecialRole(&quot;FullControl&quot;)
$p.PolicyRoleBindings.Add($fc)
$wa.Update()

#Migrate users
$wa.MigrateUsers($true)

$wa.ProvisionGlobally()
  • Create a new Managed Path
$ManagedPath = &quot;/teams&quot;
$WebApplication= &quot;http://MySharePointSrv.com&quot;
 New-SPManagedPath -RelativeURL $ManagedPath -WebApplication $WebApplication
  • Create a new Site Collection
# ---- CONFIGURATION BLOCK ----
$WebApplication= &quot;http://MySharePointSrv.com&quot;
$url = &quot;http://MySharePointSrv.com&quot;
$ContentDatabase = &quot;SP-ContentDB1&quot;
$WebsiteName = &quot;MyNewWebApp&quot;
$WebsiteDesc = &quot;&quot;
$Template = &quot;STS#1&quot;
    # STS#0 Team site
	# STS#1 Blank site
    # enter the command GET-SPWebTemplate to choose different template

# the username, display name, and email address
$PrimaryLogin = &quot;MySharePointSrv\SPSetup&quot;
$PrimaryDisplay = &quot;SPSetup&quot;
$PrimaryEmail = &quot;Sharepoint@MySharePointSrv.com&quot;

# Information about the secondary site collection administrator (Secondary Owner)
$SecondaryLogin = &quot;MySharePointSrv\SPAdmin&quot;
$SecondaryDisplay = &quot;SPAdmin&quot;
$SecondaryEmail = &quot;Sharepoint@MySharePointSrv.com&quot;

# Names of the default Members and Viewers groups
$MembersGroup = &quot;$WebsiteName Members&quot;
$ViewersGroup = &quot;Viewers&quot;
# ---- END OF VARIABLES ----

# You should not have to change any of the remaining code
# Unless you want to change the functionality of the script itself

# Create New Managed Path /
# New-SPManagedPath -RelativeURL &quot;/site1&quot; -WebApplication $WebApplication

Write-Host &quot;Creating ContentDatabase &quot;$ContentDatabase &quot;......&quot;
# Create new Content DB
New-SPContentDatabase -Name $ContentDatabase -WebApplication $WebApplication

Write-Host &quot;Creating SiteCollection &quot;$url&quot;......&quot;
# Create New Site Collection in same Content Database
New-SPSite -Url $url –ContentDatabase $ContentDatabase -Name $WebsiteName –Description $WebsiteDesc  -Template $Template -OwnerAlias $PrimaryLogin –OwnerEmail $PrimaryEmail -SecondaryOwnerAlias $SecondaryLogin -SecondaryEmail $SecondaryEmail

# default groups (Visitor, Members, and Owners)
$web = Get-SPWeb $url
$web.CreateDefaultAssociatedGroups($PrimaryLogin,$SecondaryLogin,&quot;&quot;)

$PrimaryAdmin = Get-SPUser $PrimaryLogin -Web $url
$PrimaryAdmin.Name = $PrimaryDisplay
$PrimaryAdmin.Update()
$SecondaryAdmin = Get-SPUser $SecondaryLogin -Web $url
$SecondaryAdmin.Name = $SecondaryDisplay
$SecondaryAdmin.Update()

# Finish by disposing of the SPWeb object to be a good PowerShell citizen
$web.Dispose()
  • Create a Sites and Sub-sites from an XML file

source: http://geekswithblogs.net/Norgean/archive/2012/04/12/creating-sharepoint-sites-from-xml-using-powershell.aspx Create the structure in websites.XML:

<Sites>
<Site Name="Test 1" Url="Test1" />
<Site Name="Test 2" Url="Test2" >
<Site Name="Test 2 1" Url="Test21" >
<Site Name="Test 2 1 1" Url="Test211" />
<Site Name="Test 2 1 2" Url="Test212" />
</Site>
</Site>
<Site Name="Test 3" Url="Test3" >
<Site Name="Test 3 1" Url="Test31" />
<Site Name="Test 3 2" Url="Test32" />
<Site Name="Test 3 3" Url="Test33" >
<Site Name="Test 3 3 1" Url="Test331" />
<Site Name="Test 3 3 2" Url="Test332" />
</Site>
<Site Name="Test 3 4" Url="Test34" />
</Site>
</Site>

Read this structure in Powershell, and recursively create the sites. with a progress dialog barre, too. (enter the command GET-SPWebTemplate to choose different template)

&lt;/pre&gt;

$url = &quot;http://MySharePointSrv.com&quot;
$PathFile = &quot;C:\Powershell\websites.xml&quot;
$SiteTemplate = &quot;BLANKINTERNET#2&quot; &lt;# BLANKINTERNET#2 #&gt;

$snap = Get-PSSnapin | Where-Object { $_.Name -eq &quot;Microsoft.SharePoint.Powershell&quot; }
if ($snap -eq $null)
{
 Add-PSSnapin &quot;Microsoft.SharePoint.Powershell&quot;
}

function CreateSites($baseUrl, $sites, [int]$progressid)
{
 $sitecount = $sites.ChildNodes.Count
 $counter = 0
 foreach ($site in $sites.Site)
 {
 Write-Progress -ID $progressid -Activity &quot;Creating sites&quot; -status &quot;Creating $($site.Name)&quot; -percentComplete ($counter / $sitecount*100)
 $counter = $counter + 1

Write-Host &quot;Creating $($site.Name) $($baseUrl)/$($site.Url)&quot;
 New-SPWeb -Url &quot;$($baseUrl)/$($site.Url)&quot; -AddToQuickLaunch:$false -AddToTopNav:$true -Confirm:$false -Name &quot;$($site.Name)&quot; -Template &quot;$SiteTemplate&quot; -UseParentTopNav:$true
 if ($site.ChildNodes.Count -gt 0)
 {
 CreateSites &quot;$($baseUrl)/$($site.Url)&quot; $site ($progressid +1)
 }
 Write-Progress -ID $progressid -Activity &quot;Creating sites&quot; -status &quot;Creating $($site.Name)&quot; -Completed
 }
}
# read an xml file
$xml = [xml](Get-Content $PathFile)
$xml.PreserveWhitespace = $false

CreateSites $url $xml.Sites 1
&lt;pre&gt;
  • Delete sites listed in XML file

source: http://geekswithblogs.net/Norgean/archive/2012/04/12/creating-sharepoint-sites-from-xml-using-powershell.aspx Create the structure in websites.XML:

<Sites>
<Site Name="Test 1" Url="Test1" />
<Site Name="Test 2" Url="Test2" >
<Site Name="Test 2 1" Url="Test21" >
<Site Name="Test 2 1 1" Url="Test211" />
<Site Name="Test 2 1 2" Url="Test212" />
</Site>
</Site>
<Site Name="Test 3" Url="Test3" >
<Site Name="Test 3 1" Url="Test31" />
<Site Name="Test 3 2" Url="Test32" />
<Site Name="Test 3 3" Url="Test33" >
<Site Name="Test 3 3 1" Url="Test331" />
<Site Name="Test 3 3 2" Url="Test332" />
</Site>
<Site Name="Test 3 4" Url="Test34" />
</Site>
</Site>

Read this structure in Powershell, and recursively delete the sites. this time from the latest down the hierarchy and up .  

&lt;/pre&gt;

$url = &quot;http://MySharePointSrv.com&quot;
$PathFile = "C:\Powershell\websites.xml"

$url = "http://icon-dev.norgine.com"
$PathFile = "C:\CPS\Powershell\websites.xml"

$snap = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }
if ($snap -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}

function DeleteSites($baseUrl, $sites, [int]$progressid)
{
$sitecount = $sites.ChildNodes.Count
$counter = 0
foreach ($site in $sites.Site)
{
Write-Progress -ID $progressid -Activity "Deleting sites" -status "Deleting $($site.Name)" -percentComplete ($counter / $sitecount*100)
$counter = $counter + 1

if ($site.ChildNodes.Count -gt 0)
{
DeleteSites "$($baseUrl)/$($site.Url)" $site ($progressid +1)
}
Write-Host "Deleting $($site.Name) $($baseUrl)/$($site.Url)"
		$WebSiteIdentity = "$($baseUrl)/$($site.Url)"
	   	Remove-SPWeb -Identity $WebSiteIdentity
Write-Progress -ID $progressid -Activity "Deleting sites" -status "Deleting $($site.Name)" -Completed
}
}
# read an xml file
$xml = [xml](Get-Content  $PathFile)
$xml.PreserveWhitespace = $false

DeleteSites $url $xml.Sites 1
  • Change a site collection Master Page to a Custom.master
$url = &quot;http://MySharePointSrv.com&quot;
$Scollection = &quot;&quot;
$NewMasterPage = &quot;$Scollection/_catalogs/masterpage/Custom.master&quot;

$web = Get-SPWeb $url
Write-Host $NewMasterPage
$web.CustomMasterUrl = $NewMasterPage
$web.MasterUrl = $NewMasterPage

$web.Update()
Write-Host &quot;...done.&quot;

$url = &quot;http://MySharePointSrv.com/sites/sitecol1/site1&quot;
$Scollection = &quot;/sites/sitecol1&quot;
$NewMasterPage = &quot;$Scollection/_catalogs/masterpage/custom.master&quot;

$web = Get-SPWeb $url
Write-Host $NewMasterPage
$web.CustomMasterUrl = $NewMasterPage
$web.MasterUrl = $NewMasterPage

$web.Update()
Write-Host &quot;...done.&quot;

$url = &quot;http://MySharePointSrv.com/teams/IT&quot;
$Scollection = &quot;/teams/IT&quot;
$NewMasterPage = &quot;$Scollection/_catalogs/masterpage/custom.master&quot;

$web = Get-SPWeb $url
Write-Host $NewMasterPage
$web.CustomMasterUrl = $NewMasterPage
$web.MasterUrl = $NewMasterPage

$web.Update()
Write-Host &quot;...done.&quot;

$url = &quot;http://MySharePointSrv.com/sites/sitecol1&quot;
$Scollection = &quot;/sites/sitecol1&quot;
$NewMasterPage = &quot;$Scollection/_catalogs/masterpage/custom.master&quot;

$web = Get-SPWeb $url
Write-Host $NewMasterPage
$web.CustomMasterUrl = $NewMasterPage
$web.MasterUrl = $NewMasterPage

$web.Update()
Write-Host &quot;...done.&quot;

$url = &quot;http://MySharePointSrv.com/sites/sitecol1/template&quot;
$Scollection = &quot;/sites/sitecol1&quot;
$NewMasterPage = &quot;$Scollection/_catalogs/masterpage/custom.master&quot;

$web = Get-SPWeb $url
Write-Host $NewMasterPage
$web.CustomMasterUrl = $NewMasterPage
$web.MasterUrl = $NewMasterPage

$web.Update()
Write-Host &quot;...done.&quot;

  • Remove site columns
# Set Variables
$url = &quot;http://cthub.MySharePointSrv.com&quot;
$siteColumnsList = &quot;myField&quot;  # Specify a list of Site Column Names to be deleted, seperated by ;

$site = new-object Microsoft.SharePoint.SPSite($url)
 $array = $siteColumnsList.Split(&quot;;&quot;)

$site = get-spsite $url

$web = $site.openweb()
 # go thru each content type to remove column
    foreach ($ctype in $web.ContentTypes)
     {
        foreach($colms in $array)
         {
          try
          {
            #Get link to the columnn from the web
            $spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($web.Fields[$colms])

            #Remove the column from the content type and update
            $ct.FieldLinks.Delete($spFieldLink.Id)
            $ct.Update()

             # below 2 lines is to delete from Site, when not in a ContentType
           # $column = $site.rootweb.Fields[$colms]
           # $site.rootweb.Fields.Delete($column)
           Write-Host $column.Title &quot;deleted successfully.&quot;
          }
          catch [System.Exception]
          {
           Write-Host $column.Title &quot;deleted failed.&quot;
           #Best Attempt to Remove Site Columns
          }
         }
     }
$site.Dispose()

via François on Sharepoint http://sharepointfrancois.wordpress.com/2013/04/23/collection-of-powershell-scripts-for-sharepoint-contenttype-cthub-sites-lists/

François Souyri
French native Sharepoint Consultant living in London. A crossway between a designer, developer and system architect. Prefers stretching the limit of out-of-the-box features rather than breaking them into code. When not working with Microsoft Sharepoint François is often found on Web2.0 News sites and related social networking tools.

This article has been cross posted from sharepointfrancois.wordpress.com/ (original article)

Categories: Work Tags: ,

#Project #MVP Award #ProjectServer #SharePoint #PS2013# SP2013

April 22, 2013 Leave a comment
Paul Mather
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011.
I am also a certified Prince2 Practitioner.

This article has been cross posted from pwmather.wordpress.com (original article)

I am very pleased to announce that I was awarded the MVP award for Project in April 2013. I am grateful for such recognition for doing something I really enjoy, helping out fellow Project Server community members. I have been holding off announcing the award as my surname is wrong on the award, it states Paul Mathers instead of Paul Mather. This is something that is being corrected but will take time.

MVP

I look forward to continuing helping out in the Project,Project Server and SharePoint communities. Smile

Categories: Paul Mather, Work Tags:

Sign-in as different user on #SharePoint Server 2013 or #ProjectServer 2013

April 21, 2013 Leave a comment
While browsing/using your new SharePoint Server 2013 web site, one of the evident feature missing you will come across, apart from the other UI changes, is when you trying to log-in as a different user by clicking on top rite corner of the page and found NOTHING 🙂

I have seen on few blog posts that it could be the case with preview version, and in RTM we mite get it back. but i am using RTM now and its the same as of preview version. Your other clue at this stage could be that it might needs to be enabled from some setting options, but for your information that is not true either 🙂
After a little googling i have found that this feature has been removed on purpose by Microsoft from SharePoint server 2013. Although this is pretty much a frequent option to be used by developer/consultants while testing solution, however following are the few reasons explained by Microsoft due to which it has been removed:

  • Caching Problems
  • Documents opened in external applications are saved with an unexpected user account
  • Page content shows information from the previous user due to cached information
  • Session variables contain information from previous user as the cookies are not cleared

As an end user perspective, i agree that its a good move to avoid issues by removing this option since end user do not often requires to switch between log-in user. But as an IT pro, i don’t think i can live without it 🙂 and you can follow the below steps to bring the option back for you:

  • Locate and then open the following file in a text editor:  C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\welcome.ascx
  • Open the file in Notepad and add the following lines to the file: also see the screen shot for this modification.
<SharePoint:MenuItemTemplate runat=”server” ID=”ID_LoginAsDifferentUser” 
Text=”<%$Resources:wss,personalactions_loginasdifferentuser%>” 
Description=”<%$Resources:wss,personalactions_loginasdifferentuserdescription%>” 
MenuGroupId=”100″ 
Sequence=”100″  UseShortId=”true” /> 
  • As a final step, refresh the page and the option will apparently start appearing for you to be used.
One of the other alternative is to start Internet Explorer as Run as Different User and login to SharePoint site: http://support.microsoft.com/kb/2752600
Note: I came across this while evaluating Project Server 2013 PWA site, however it applies to any SharePoint site and not limited to PWA only because its all SharePoint 🙂  Also as i have mentioned that this option is removed intentionally, so try this on your testing environments prior to apply on production.

via All about Enterprise Project Management (EPM) http://khurramjamshed.blogspot.com/2013/04/sign-in-as-different-user-on-sharepoint.html

Khurram Jamshed
The author of the blog has an extensive experience of working as an EPM Consultant. Currently he is located in Dubai, UAE and working for Microsoft partner organization as Project Server specialist. He has a thorough experience of providing Project Management technical/functional consultancy to all sort of organizations. He is a certified PMP, a Project Server MCITP, and also received a MS community contributor award 2011.

This article has been cross posted from khurramjamshed.blogspot.com/ (original article)

Design a site like this with WordPress.com
Get started