Branding your SharePoint Sites

Branding your SharePoint Site and adding your custom masterpage, stylesheet, logo and favicon is fun and, thanks to Thomas Balkeståhl, its also rather simple.

Thomas has done a great job releasing a SharePoint 2010 Branding Project that helps you brand your SharePoint 2010 sites. And the best part: It’s free :)

Check it out Here

Rating 4.50 out of 5

SharePoint & PowerShell Week @ScriptingGuys

Recently I wrote a couple of posts for ScriptingGuys, describing how to use SharePoint 2010 and PowerShell. Many of the examples from the post are from my and Mattias Karlsson’s book: PowerShell for SharePoint 2010 Administrators, which will be released October 29, this year.

You can check out the SharePoint & PowerShell Week posts here:

Get Started Managing SharePoint 2010 with PowerShell Cmdlets

Use SharePoint 2010 PowerShell Cmdlets to Get and Manage Sites

Use PowerShell to Manage Lists, Views, and Items in SharePoint

Use PowerShell Cmdlets to Manage SharePoint Document Libraries

Rating 2.00 out of 5

Australian & New Zealand SharePoint Conference

I just finished my Australian/New Zealand SharePoint & PowerShell tour with Mattias Karlsson where we had the honor to speak at both the New Zealand and the Australian SharePoint conference. In our session SharePoint 2010 and PowerShell – In real life we showed a couple of demos and promised to share them on this site. So here they are.

Click here to download the scripts

Click here to download the PowerPoint presentation

Rating 3.00 out of 5

MOSS 2007 Script Collection

I’ve been working with SharePoint and PowerShell for quite some time now and I would like to share a couple of Scripts that I use when scripting MOSS. Actually, it’s 44 Scripts, Loads of Coffee and alot of long nights :) so I hope you enjoy them. There are Links at the bottom of the Post where you can Download all the scripts, or you can Download all scripts from the link below.

Down to business then. I’ll put up a scenario based on the Session that I used at the SharePoint UserGroup meeting in Stockholm Sweden, explaining all Steps and how to use the Scripts.

First I set up a Folder where I keep all my scripts, I use C:\Scripts. Then I add the folder to the Windows Path.

PS > $env:path = $env:path + ";c:\scripts"


Adding the Script folder to the Environment Path let’s Us Call the script simply by typing it’s name. so instead of typing:

PS > .\Get-SPSite.ps1 -url http://moss


We can Type:

PS > Get-SPSite -url http://moss


Note, Don’t forget to set the Execution-Policy, otherwise, the scripts won’t run. Read more about it here

PS > Set-ExecutionPolicy RemoteSigned


All Scripts include a help text that explains how to use the Script. To access the helptext simply type the Script Name followed by -help.

PS > Get-SPSite -help


Now We can start Scripting MOSS!

Loading SharePoint Assemblies


The first thing we have to do in order to Access the MOSS 2007 Assemblies is Loading them into PowerShell. Even though they Exist in our Windows Environment, PowerShell isn’t aware of them. By Loading them into our Global Assembly Cache, PowerShell can access and use the MOSS 2007 .NET Classes.





First, We’ll Check out the Site Collection. Here’s how we can add our Site Collection to a variable using the Get-SPSite.ps1 script and retrieve information from it. When working with SPSite or OpenWeb objects in the PowerShell console you have to dispose of the object on the same row as the command, otherwise they will leak memory. This only applies when you create SharePoint objects directly in the PowerShell console. When run in functions and scripts, the commands are run in a single thread. for more information click here

PS > $SPSite = Get-SPSite -url http://moss; $SPSite | Select Url, Port, Owner | Format-List; $SPSite.Dispose()

Url   : http://moss
Port  : 80
Owner : POWERSHELL\administrator

We can also get usage Information:

PS >  $SPSite = Get-SPSite -url http://moss; $SPSite.Usage; $SPSite.Dispose()

Storage           : 550113
Bandwidth         : 0
Visits            : 0
Hits              : 0
DiscussionStorage : 0


And even information from the WebApplication Pool 

PS > $SPSite = Get-SPSite -url http://moss; $SPSite.WebApplication.ApplicationPool | Select DisplayName, Status | Format-List; $SPSite.Dispose()

DisplayName : SharePoint - 80
Status      : Online


Try Pipe:ing the $SPSite object to Get-Mameber and check out all Available methods and properties available. 

PS > $SPSite = Get-SPSite -url http://moss; $SPSite | Get-Member; $SPSite.Dispose()




The Get-SPWeb.ps1 Returns a Site instead of a Site Collection through the OpenWeb() method. Through it, we can modify the Title and description of a site, we can add Items, documents and lots more. Here’s an example on how you can change the Title and Descrition of a Site. 

PS > $OpenWeb = Get-SPWeb http://moss; $OpenWeb.Title; $OpenWeb.Dispose()


PS > $OpenWeb = Get-SPWeb http://moss; $OpenWeb.Description; $OpenWeb.Dispose()


PS >  $OpenWeb = Get-SPWeb http://moss; $OpenWeb.Title = "PowerShell Home"; $OpenWeb.Description = "Demo From"; $OpenWeb.Update(); $OpenWeb.Dispose()


Here’s What happened to my MOSS RootWeb Site after running these simple commands. 




We’ve accessed The Site Collection and a MOSS Site, Let’s look at how to access a List within a Site. We can do this through the Get-SPList.ps1 Script. We can use it to Get or Set List Information and even Get or Set Items and Fields in the List. 

PS > $SPList = Get-SPList -url http://moss -List Announcements; $SPList.ItemCount; $SPList.Dispose()


PS > $SPList = Get-SPList -url http://moss -List Announcements; $SPList.Items | ForEach { $_["Title"] }; $SPList.Dispose()

Get Started with Windows SharePoint Services!
Announcement Added through PowerShell
Demo from




A List Contains Field which tell us what kind of information we can add to our Items. When Accessing a Field you can use the Get-SPField.ps1 script. The Field holds alot of information such as Type. 

PS > $Field = Get-SPField -url http://moss -List Announcements -Field Expires
PS > $Field.Type



You can even edit information in the Field. Here’s an Example on How to Hide the Field in Edit Form. When a User Tries to Edit an item in the Announcements List, he won’t see the Expires Field. 

PS > $Field.ShowInEditForm = $False
PS > $Field.Update()




A List Contains a Variaty of Views. Here’s how you Access a List View in MOSS 2007 using the Get-SPView.ps1 Script. 

PS > $View = Get-SPView -url http://moss -List "Shared Documents" -View "All Documents"


The View contains alot of Methods and Properties. Let’s take a look at the Clone() Method. 

PS > [void]$View.Clone("My Cloned View",100,$True,$False)


With this Simple Command, I’ve Created a new View Called “My Cloned View”. It’s basically a Copy of the “All Documents” View. 



When Accessing Items within a List, you can use the Get-SPItem.ps1 Script. Storing the Item in a Variable Allows us to Get And Modify it’s properties. The script includes an -All Switch that retrieves All Items in a List instead of just one item. 

PS > $Item = Get-SPItem  -url http://moss -List Announcements -Item "Get Started with Windows SharePoint Services!"


Now That we have an Item stored in the $Item Variable, we can Modify it. 

PS > $Item["Body"]

Microsoft Windows SharePoint Services helps you to be more eff ective by connecting people, information, and documents. For information on getting started, see Help.
PS > $Item["Body"] = "New Text in Body" PS > $Item.Update()


Another Nice Trick is Looping through all Items. First let’s Store them in a variable: 

PS > $AllItems = Get-SPItem -url http://moss -List Announcements -All

Now Let’s Set the Body on All Announcements in the Announcements List.

PS > $AllItems | ForEach { $_["Body"] = "New Text"; $_.Update() }




Next, let’s add an Announcement to our RootWeb Site. Using the Add-SPAnnouncement.ps1 sript, we can add through a One-Liner in PowerShell. 

PS > Add-SPAnnouncement -url http://moss -List "Announcements" -Title "Demo from" -Body "<h1>PowerShell</h1><p />is Cool!" -Expires (Get-Date).AddHours(1)



Let’s say that you have multiple sites in your Site Collection and you want to add an Announcement on each site. This can be solved with a Simple ForEach: 

PS > $Sites = "http://moss/HR","http:moss/IT","http://moss/Production","http://moss/Sales"
PS > $Sites | ForEach {
>> Add-SPAnnouncement -url $_ -List "Announcements" -Title "Demo från" -Body "

is Coolt!" -Expires (Get-Date).AddHours(1)


This Code adds an announcement on each site in the $Sites Array. 



The Add-SPCalendar.ps1 script adds new Calendar Entries to a MOSS Calendar List. 

PS > Add-SPCalendar -url http://moss -List "Calendar" -Title "SharePoint - PowerShell Demo" -Location "Stockholm" -Description "PowerShell Demo" -StartTime (Get-Date) -EndTime (Get-Date).AddHours(4)


The -StartTime and -EndTime Parameters accept an [DateTime] object, which means that we can use the Get-date CmdLet to Add Dates. 




Here’s a Script that adds Links to a MOSS Links List. It sets the Link, the Description of the Link and the Notes Field. 

PS > Add-SPLink -url http://moss -List "Links" -Link "" -Description " - Blog" -Notes "PowerShell Blog"


Here’s what our Newly created Link Item looks like: 




On a Default installed MOSS, The Root Web uses the “Team Site” Template, which has an Image WebPart on the Right Displaying a SharePoint Services Image. Let’ go ahead and change the image using the Set-SPImageWebPart.ps1 Script. 

PS > Set-SPImageWebPart -url http://moss -WebPart "Site Image" -Image "C:\Demo\Files\PowerShell.jpg"


As you can see in the Image below, Our RootWeb Team Site looks a little PowerShelled. 



Now that we’ve customized our Site with a New “Site Image”, let’s go ahead and change the Theme. We’ll use the Set-SPTheme.ps1 script to achieve this.

PS > Set-SPTheme -Url http://moss -Theme obsidian


And with a simple One-Liner, we’ve changed the Theme on our Site. Doing without the script takes about two lines of code, but i Added the script since I think it’s pretty cool. 




This Script lets you Upload Documents to a Document Library in MOSS. Here’s how it Works: 

PS > Upload-SPDocument -url http://moss -Folder "Shared Documents" -Document "C:\Documents\Excel SpreadSheet.xlsx"


If we look in our “Shared Documents” List, We can see that the Document is uploaded there now. 


But What it we want to Upload one hundred documents ? Well, since we are using PowerShell, we can do it with a One-Liner. 

PS > gci C:\Documents | ForEach { Upload-SPDocument -url http://moss -Folder "Shared Documents" -Document $_.FullName }


This really shows the Power of Microsoft PowerShell 



Now That we’ve Uploaded a couple of Files, Let’s Add a New Folder to our “Shared Documents”. We can do this by using the Add-SPFolder.ps1 script. 

PS > Add-SPFolder -Url http://moss -List "Shared Documents" -Name "New Folder"


If we want to Upload Documents Directly to our Folder we can use the Upload-SPDocument.ps1 Script again, we just point it to our New Folder. 

PS > Upload-SPDocument -url http://moss -Folder "Shared Documents/New Folder" -Document "C:\Documents\Excel SpreadSheet.xlsx"




Let’s add a couple of Fields to our “Shared Documents” List. First, we’ll add a Document Owner Field. In this example we’ll use a simple Text field, but you could obviously use a User field instead. We’ll get back to the User field a little later in this post. 

PS > Add-SPTextField -url http://moss -List "Shared Documents" -Name "Document Owner" -Description "Document Owner"


This Adds a TextField to our List named “Document Owner”, if you want the field to Require information, simply add -Required to the command above. 




Next, We’ll add a Choice Field to our “Shared Document”. This can be done by using the Add-SPChoiceField.ps1 Script. Again, if you want the Field to Require information, just add -Required to the command. 

PS > Add-SPChoiceField -url http://moss -List "Shared Documents" -Name "Document Type" -Description "Type of Document" -Choices $("Excel","Word","PowerPoint")


Note the -Choices Paramteter. It takes an Array of arguments and Sets each argument as a Choice in the Field. Typing $(“Argument1″,”Argument2″) is a quick way to create an array and passing it as an argument to the script. 




Now that we have two new Fields in our “Shared Documents”, let’s add them to the “All Documents” View by using the Add-SPFieldToView.ps1 Script. 

PS > Add-SPFieldToView -url http://moss -List "Shared Documents" -Field "Document Owner" -View "All Documents"
PS > Add-SPFieldToView -url http://moss -List "Shared Documents" -Field "Document Type" -View "All Documents"


If we check out our “Shared Documents” list now, we can see that the Fields are Added to the “All Documents” View. You can, of course, use this on any type of List in MOSS 2007. 




Here’s a Really Useful script when working with Items. The Set-SPItem.ps1 Script can either Create a New Item or Modify an existing Item. At first, Let’s take a look on how to Modify existing Items. By Default, the -field param is set to Title, but by changing it to Name, the script will check for a match in the Name Field and if it finds a match, it will update the Item, if it doesn’t find a match it will create a New Item. Note that when Creating Items in a Document Library you have to use the Upload-SPDocument.ps1 script. 

Note that the -Values takes a HashTable Array of Values to Set on the Item. Let’s say a List has Two Fields. A Title field and a Description Field. If I want to Create a New Item Called “New Item” and with The Description “My New Item Description” I could Simply type: 

PS > Set-SPItem -url http://moss -List "My List" -Name "New Item" -Values @{"Description" = "My New Item Description"}


If i Want to Edit the Item that i Created i Could reuse the Same Command, since it First looks for an Item Where the Title is Set to “New Item” 

Let’s say i Don’t know the Title of the Item but i Do know It’s Description. By using the -Field paramter i Could get the Correct Item and Modify it. 

PS > Set-SPItem -url http://moss -List "My List" -Name "My New Item Description" -Field Description -Values @{"Title" = "New Title"; "Description" = "Changed Title and Changed Description of Item"}


Let’s Take a Look at the Documents that we Added earlier. Here’s an example on adding MetaData on Documents in a Document Library:

PS > Set-SPItem -url http://moss -List "Shared Documents" -Name "Excel SpreadSheet.xlsx" -Field "Name" -Values @{"Document Type" = "Excel"; "Document Owner" = "Niklas Goude"}
PS > Set-SPItem -url http://moss -List "Shared Documents" -Name "Word Document.docx" -Field "Name" -Values @{"Document Type" = "Word"; "Document Owner" = "Niklas Goude"}
PS > Set-SPItem -url http://moss -List "Shared Documents" -Name "PowerPoint Presentation.pptx" -Field "Name" -Values @{"Document Type" = "PowerPoint"; "Document Owner" = "Niklas Goude"}


With these Commands I added information in the “Document Type” Field and the “Document Owner” Field on my three Documents, as the image below show. 


Let’s Use this Script to Modify the Announcement That we Added Earlier. We’ll Change the Body of the Announcement. 

PS > Set-SPItem -url http://moss -List Announcements -Name "Demo from" -Values @{"Body" = "<h2>Modified With Set-SPItem.ps1</h2>"}


Here’s what the Announcemet looks like now: 




Now Let’s create our own Custom List. We’ll use the Add-SPList.ps1 Script to do this. Specifying the Type to “Custom List” tells the script to create a “Custom List”. You can, of course create any type of list available in MOSS through this script. 

PS > Add-SPList -url http://moss -Name "My List" -Description "My Custom Demo List" -Type "Custom List"


This Creates the List, but it doesn’t Add the List to the QuickLaunch Bar. Let’s check out how to Add a List to the QuickLaunchBar. 



This Script adds lists to the Quicklaunch Bar in MOSS 2007. The Command below shows how you can use the script. 

PS > Add-SPListToQuickLaunch -url http://moss -List "My List"


This command adds the List to the QuickLaunch Bar. 




Let’s Change the QuickLaunch Order. We’ll use the Set-SPQuickLaunchOrder.ps1 Script that moves a List to the Top of the QuickLaunch. 

PS > Set-SPQuickLaunchOrder -url http://moss -List "My List"


If we look at our site now, We can see that our QuickLaunch Order has been Changed. The “My List” List is now on top. 


Now That we have a Custom List, Let’s Add a couple of different Fields, We’ll also add them to the “All Items” View with the Add-SPFieldToView.ps1 script. 



You can Add a Currency Field by using the Add-SPCurrencyField.ps1 Script. 

PS > Add-SPCurrencyField -url http://moss -List "My List" -Name Cash -Description "How much Money do you have?"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field Cash -View "All Items"




Here’s how we can add a DateTime Field to a List using the Add-SPDateTimeField.ps1 Script. 

PS > Add-SPDateTimeField -url http://moss -List "My List" -Name "Birthday" -Description "When is Your Birthday?"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field Birthday -View "All Items"




The Note Field Accepts Text on Multiple Rows. Here we add a Note Field using the Add-SPNoteField.ps1 Script. 

PS > Add-SPNoteField -url http://moss -List "My List" -Name Description -Description "About Me.."
PS > Add-SPFieldToView -url http://moss -List "My List" -Field Description -View "All Items"




We can also Add Numeric Fields to MOSS. This example shows how to do that using the Add-SPNumberField.ps1 Script. 

PS > Add-SPNumberField -url http://moss -List "My List" -Name Age -Description "How Old Are You?"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field Age -View "All Items"




With the Add-SPYesNoField.ps1 script, We can add a Yes/No Checkbox Field to our List. 

PS > Add-SPYesNoField -url http://moss -List "My List" -Name "Windows 7" -Description "Do You Have Windows 7 Installed?"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field "Windows 7" -View "All Items"




Adding User Fields that point to a Active-Directory User, Can be Added through the Add-SPUserField.ps1 Script. 

PS > Add-SPUserField -url http://moss -List "My List" -Name User -Description "User"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field User -View "All Items"




A User Field can Allow Multiple Selections. Here’s how to add a multiple User Field using the Add-SPMultipleUserField.ps1 script. 

PS > Add-SPMultipleUserField -url http://moss -List "My List" -Name "Multiple Users" -Description "Multiple Users"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field "Multiple Users" -View "All Items"




Choice Fields can also accept Multiple Choices. Here’s an example on how to add a Multiple Choice Field using the Add-SPMultiChoiceField.ps1 Script. 

PS > Add-SPMultiChoiceField -url http://moss -List "My List" -Name "Favorite Music" -Description "Favorite Music" -Choices $("Country","Metal","Rock","Soul","Jazz")
PS > Add-SPFieldToView -url http://moss -List "My List" -Field "Favorite Music" -View "All Items"



The Lookup Field Points to an Item in another List. In this Example we’ll Point it to the “Tasks” List.

PS > Add-SPLookupField -url http://moss -List "My List" -Name "My Tasks" -Description "My Tasks" -LookupList Tasks
PS > Add-SPFieldToView -url http://moss -List "My List" -Field "My Tasks" -View "All Items"




LookupFields Can also have multiple Values. We can add a Multiple LookupList through the Add-SPMultiLookupField.ps1 Script. Again, We’ll Use the Tasks List as Lookup. 

PS > Add-SPMultiLookupField -url http://moss -List "My List" -Name "Multiple Tasks" -Description "Multiple Tasks" -LookupList Tasks
PS > Add-SPFieldToView -url http://moss -List "My List" -Field "Multiple Tasks" -View "All Items"




Finally, Let’s Add an URL Field to our “Custom List”. 

PS > Add-SPURLField -url http://moss -List "My List" -Name HomePage -Description "HomePage"
PS > Add-SPFieldToView -url http://moss -List "My List" -Field HomePage -View "All Items"


Now, Let’s see what our List Looks like. 


Let’s Add Two Task Items and then create a New Item in our “Custom List” using the Set-SPItem.ps1 Script. 

PS > Set-SPItem -url http://moss -List Tasks -Name "My First Task" -Values @{"Priority" = "(3) Low"; "Status" = "In Progress"; "% Complete" = "0.4"; "Assigned To" = "powershell\Administrator"; "Description" = "My First Task"; "Start Date" = "09/07/09"; "Due Date" = "09/08/09"}
PS > Set-SPItem -url http://moss -List Tasks -Name "My Second Task" -Values @{"Priority" = "(1) High"; "Status" = "Not Started"; "% Complete" = "0"; "Assigned To" = "powershell\Administrator"; "Description" = "My Second Task"; "Start Date" = "09/07/09"; "Due Date" = "09/08/09"}


Here’s our New Tasks up and running. 


Now Let’s Add a New Item in our “Custom List”. Note that Fields that Allow multiple Values are divided by a ; in the command below. For Instance, if I want to two values to a multiple Choice Field I would have to Type: @{“MultiChoiceField” = “Value1; Value2; Value3″}.

PS > Set-SPItem -url http://moss -List "My List" -Name "My First Item" -Values @{"Cash" = "10"; "Birthday" = "05/05/1982"; "Description" = "My First Entry"; "Age" = "27"; "Windows 7" = "Yes"; "User" = "powershell\administrator"; "Multiple Users" = "powershell\administrator; powershell\nigo"; "Favorite Music" = "Metal; Country"; "My Tasks" = "My First Task"; "Multiple Tasks" = "My First Task; My Second Task"; "HomePage" = "; My Blog" }


And Here’s what our Item Looks like in MOSS 2007. 



Let’s Modify the Apperance of the “All Tasks” View in the Tasks List so that it Groups By Status. When Modifying appearance of a View, We change the View Query. This can be Done by using the Set-SPView.ps1 Script.

PS > Set-SPView -url http://moss -List Tasks -View "All Tasks" -Query ''


Here’s what our Tasks Look like now. 


Remember the “Shared Documents that We Added Fields to earlier ? Let’s Group the “All Documents” View by one of our New Fields. Note that the Name=”Document_x0020_Type” in the Query. It’s because the Field has Spaces in its Name. 

PS > Set-SPView -url http://moss -List "Shared Documents" -View "All Documents" -Query ''


And now our Documents are Grouped by “Document Type”. 




With the Add-SPSite.ps1 Script, we can add New Sites to our Site Collection. There are a Couple of Different Templates that we can use. To get a list of all templates available, SImply type the following commands. 

PS > $OpenWeb = Get-SPWeb http://moss; $OpenWeb.GetAvailableWebTemplates(1033) | Select Name; $OpenWeb.Dispose()


Let’s Create a New Site For our IT Department. 

PS > Add-SPSite -url http://moss -weburl "IT" -Title "Information Technology" -Description "IT Department" -Template "STS#1"


Here’s What the Site looks like now. 


Since we used a STS#0 Template, the Site doesn’t contain any Lists or information. 



If we want to Add a New Group to our Site Collection we can use the Add-SPGroup.ps1 Script. Here’s an example on using the Script. 

PS > Add-SPGroup -url http://moss -Group "New Group" -Role Read -Owner "powershell\administrator"


Now our “New Group” is Added to our Site with “Read” Permissions 




With our New Group set up, we can go ahead and add users to it. To accomplish this, we can use the Add-SPUser.ps1 Script. Here’s an example on adding a User to the “New Group”.

PS > Add-SPUser -url http://moss -Group "New Group" -Domain "" -sAMAccountName "goude" -mail "" -FullName "Niklas Goude"


If we look in the Group now, our User will be added. 




Let’s Give our Group Full Permissions on The IT Site that we created earlier.

PS > Add-SPSitePermission -url "http://moss/IT" -Group "New Group" -Permission "FullMask"


Now all users in the Group have Full Permissions on the “IT” Site. On the RootWeb, they still have Read Permissions. 



Let’s Add a New Image WebPart to the IT Site that we just created. Here’s an example on how to do it using the Add-SPImageWebPart.ps1 Script.

PS > Add-SPImageWebPart -url http://moss/IT -Name "My Image" -Image "C:\Images\PowerShell.jpg" -ChromeType "None"


Now the Image WebPart is Added to the Site. There are a couple of parameters you can use with this script. simply type Add-SPImageWebPart -help to check out available parameters. 

PS > Add-SPImageWebPart -help





The Add-SPListViewWebPart.ps1 let’s us Add list View WebParts to our Sites. The Script contains a couple of parameters that let’s you choose Chrome Type, Zone and a couple of other things. Here’s an example on Using the Script.

PS > Add-SPListViewWebPart -url http://moss -List "My List" -Name "Client Statistics" -ChromeType "None"


Here’s our New List WebPart in Action! 




If you want to Remove a Field From a List you can use the Remove-SPField.ps1 Script. Here’s an example on how to use the Script.

PS > Remove-SPField -url http://moss -List "Shared Documents" -Field "Document Type"




If you want to Remove a List Item you can use the Remove-SPItem.ps1 script. The -name parameter matches with the Title field by default. If you want to match the name with another field, simply use the -field parameter.

PS > Remove-SPItem -url http://moss -List Tasks -name "My First Task"
PS > Remove-SPItem -url http://moss -List Tasks -name "Not Started" -Field Status




If you want to Remove an entire List you can use the Remove-SPList.ps1 script,

PS > Remove-SPList -url http://moss -List Tasks


This Command Removed the Tasks List from the RootWeb Site. 



When Removing a Site from MOSS 2007 You can use the Remove-SPSite.ps1 script. This exmaple shows how to remove the IT Site that we created earlier.

PS > Remove-SPSite -url http://moss/IT




Let’s take a Backup of our Site Collection. We can either do this through Central Administration, through an STSADM Command or by Using PowerShell. This Example shows how to use a PowerShell Script to take a Backup of a Site Collection.

PS > Export-SPSite -url http://moss -file Backup.bak -Location C:\Backup\


The Command Places a Backup file in C:\Backup\Backup.bak. to automate this you could set up a Scheduled Task that takes a backup at specified weekdays. 



Now That we have a Backup, Let’s restore our Site Collection from the Backup file. To achieve this, we can use the Import-SPSite.ps1 Script. Here’s an example on how to use the script.

PS > Import-SPSite -url http://moss -file Backup.bak -Location C:\Backup\


Here’s a List of All scripts from this Post. Enjoy! 




Rating 3.50 out of 5

SharePoint and PowerShell – In real life

I’ve had for quite some time now, gathering information and writing posts on various ways of solving issues through PowerShell, tips and trix and How too’s that have been both fun and educational for me and hopefully for the people reading my blog.

I think it’s a journey worth taking, not just for the fun of writing but for the people I get to meet and the experiences that we can share through blogs, forums and communities.

One person I’ve met and shared ideas with is Mattias Karlsson. We work at the same company and we share a passion for SharePoint. Mattias is one of the best administrators i know and he’s amazing when it comes to SharePoint. We started of with an idea of sharing our SharePoint experience through cross-blogging, letting people around the world take part of our ideas and help us expand our knowledge through communities, meetings and comments.

Our idea grew to realization and today, we are writing a book on the subject. A large portion of the book will evolve around hands on scenarios and examples that IT administrators will feel familiar with.

We are currently in the beginning of the process so we can’t communicate a deadline yet. We have however set up a website where you can register your email address to get news and updates regarding the Book. This site will also act as our communication point which will develop along the way as our writing is progressing.

We are both really exited about our new project and will of course keep you posted on our blogs, so drop by now and then and send a mail if you have any tips or recommendations in our progress.

SharePoint and PowerShell – In real life

Mattias Karlsson

Rating 3.00 out of 5