Archive
#CSS Change the style of the View Selector in lists/libraries breadcrumb
As part of a site branding exercise the breadcrumbs that is displayed when a list or library is open on a view was causing issue. When hovering the current view name its font was bigger and the CSS was not obvious to target.
not good hover:

good hover:

Having spent a good hour on that single issue and Googled for solution, here is my finding for later reference.
/* keep same font and position when hovering on view name */
.ms-ltviewselectormenuheader .ms-viewselector{
padding-bottom:0px;
padding-left:5px;
padding-right:3px;
padding-top:2px;
margin-right:0px;
}
.ms-ltviewselectormenuheader .ms-viewselectorhover A{
border:0px !important;
font-family: Verdana, Helvetica ;
color: #0060ad;
font-weight: normal;
background-color: transparent;
font-size: 9px;
text-decoration: underline !important;
background-image: none;
padding-bottom:0px;
padding-left:0px;
padding-right:3px;
padding-top:2px;
margin-right:0px;
}
/* down arrow to select view */
.ms-ltviewselectormenuheader .ms-viewselector-arrow{
margin:0px 5px 2px 0px !important;
}
References:
- http://sharepoint.stackexchange.com/questions/27507/disabling-javascript-from-overriding-breadcrumb-navigation-styling
- http://www.ericjochens.com/2012/11/css-style-sharepoint-2010-branding.html
- http://sharepointexperience.com/csschart/csschart.html
via François on Sharepoint http://sharepointfrancois.wordpress.com/2013/06/06/css-change-the-style-of-the-view-selector-in-listslibraries-breadcrumb/
|
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) |
Collection of #Powershell Scripts for Sharepoint #ContentType #CTHub #Sites #Lists
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
Add-PsSnapin Microsoft.SharePoint.PowerShell
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint')
- Activate Taxonomy feature option under Site Collection Administration
# 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 "UNPUBLISHED [CONTENT TYPE GROUP] $contentTypeGroup, $contentTypeName"
}
}
$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 "PUBLISHED [CONTENT TYPE GROUP] $contentTypeGroup, $contentTypeName"
}
}
$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 "MetadataHubTimerJob" $ctHubTJ.RunNow() #Run the Content Type Subscriber timer job for a specific Web Application $ctSubTJ = Get-SPTimerJob "MetadataSubscriberTimerJob" -WebApplication http://MySharePointSrv.com $ctSubTJ.RunNow() echo "Metadata Hub Job initiated"
- 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 |
<# Create Content Type
#http://jaclynsaito.wordpress.com/2011/06/07/create-a-sharepoint-2010-content-type-using-powershell/
#>
# Set Variables
$url = "http://cthub.MySharePointSrv.com"
$cGroup = "MyContentTypes Group"
# Read list of document template to create CT
$DocumentTemplatesArray = Get-Content "C:\temp\IMPORTFILES.txt"
$CTHubSiteColl = "http://cthub.MySharePointSrv.com"
$site = get-spsite $url
$web = $site.openweb()
$ctypeParent = $web.availablecontenttypes["Document"]
# Loop thru the number of CT to create
$i = 0
$MaxCT = $DocumentTemplatesArray.count # total CT to create
write-host "--------" + $DocumentTemplatesArray.count total lines read from file + "-------"+
foreach ($line in $DocumentTemplatesArray)
{
$templateURL = "/DocumentTemplates/" + $ctypeName # URL of templatefile with extension
$ctypeName = $line.replace(".doc","").replace(".xls","").replace(".vst","").replace(".xltx","") #name of CT without extension
Write-Host $i + ": " + $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
<# Publish Content Type #http://www.jeffholliday.com/2011/08/powershell-script-create-content-type.html #>#
write-Host "---- now publish to : " + $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 </div>
- 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 = "http://MySharePointSrv.com" $wa = get-SPWebApplication $WebAppName $wa.UseClaimsAuthentication = $true $wa.Update() #configure the policy to enable the user to have full access $account = "MySharePointSrv\SPSetup" $account = (New-SPClaimsPrincipal -identity $account -identitytype 1).ToEncodedString() $wa = get-SPWebApplication $WebAppName $zp = $wa.ZonePolicies("Default") $p = $zp.Add($account,"PSPolicy") $fc=$wa.PolicyRoles.GetSpecialRole("FullControl") $p.PolicyRoleBindings.Add($fc) $wa.Update() #Migrate users $wa.MigrateUsers($true) $wa.ProvisionGlobally()
- Create a new Managed Path
$ManagedPath = "/teams" $WebApplication= "http://MySharePointSrv.com" New-SPManagedPath -RelativeURL $ManagedPath -WebApplication $WebApplication
- Create a new Site Collection
# ---- CONFIGURATION BLOCK ----
$WebApplication= "http://MySharePointSrv.com"
$url = "http://MySharePointSrv.com"
$ContentDatabase = "SP-ContentDB1"
$WebsiteName = "MyNewWebApp"
$WebsiteDesc = ""
$Template = "STS#1"
# 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 = "MySharePointSrv\SPSetup"
$PrimaryDisplay = "SPSetup"
$PrimaryEmail = "Sharepoint@MySharePointSrv.com"
# Information about the secondary site collection administrator (Secondary Owner)
$SecondaryLogin = "MySharePointSrv\SPAdmin"
$SecondaryDisplay = "SPAdmin"
$SecondaryEmail = "Sharepoint@MySharePointSrv.com"
# Names of the default Members and Viewers groups
$MembersGroup = "$WebsiteName Members"
$ViewersGroup = "Viewers"
# ---- 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 "/site1" -WebApplication $WebApplication
Write-Host "Creating ContentDatabase "$ContentDatabase "......"
# Create new Content DB
New-SPContentDatabase -Name $ContentDatabase -WebApplication $WebApplication
Write-Host "Creating SiteCollection "$url"......"
# 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,"")
$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)
</pre>
$url = "http://MySharePointSrv.com"
$PathFile = "C:\Powershell\websites.xml"
$SiteTemplate = "BLANKINTERNET#2" <# BLANKINTERNET#2 #>
$snap = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }
if ($snap -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
function CreateSites($baseUrl, $sites, [int]$progressid)
{
$sitecount = $sites.ChildNodes.Count
$counter = 0
foreach ($site in $sites.Site)
{
Write-Progress -ID $progressid -Activity "Creating sites" -status "Creating $($site.Name)" -percentComplete ($counter / $sitecount*100)
$counter = $counter + 1
Write-Host "Creating $($site.Name) $($baseUrl)/$($site.Url)"
New-SPWeb -Url "$($baseUrl)/$($site.Url)" -AddToQuickLaunch:$false -AddToTopNav:$true -Confirm:$false -Name "$($site.Name)" -Template "$SiteTemplate" -UseParentTopNav:$true
if ($site.ChildNodes.Count -gt 0)
{
CreateSites "$($baseUrl)/$($site.Url)" $site ($progressid +1)
}
Write-Progress -ID $progressid -Activity "Creating sites" -status "Creating $($site.Name)" -Completed
}
}
# read an xml file
$xml = [xml](Get-Content $PathFile)
$xml.PreserveWhitespace = $false
CreateSites $url $xml.Sites 1
<pre>
- 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 .
</pre>
$url = "http://MySharePointSrv.com"
$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 = "http://MySharePointSrv.com" $Scollection = "" $NewMasterPage = "$Scollection/_catalogs/masterpage/Custom.master" $web = Get-SPWeb $url Write-Host $NewMasterPage $web.CustomMasterUrl = $NewMasterPage $web.MasterUrl = $NewMasterPage $web.Update() Write-Host "...done." $url = "http://MySharePointSrv.com/sites/sitecol1/site1" $Scollection = "/sites/sitecol1" $NewMasterPage = "$Scollection/_catalogs/masterpage/custom.master" $web = Get-SPWeb $url Write-Host $NewMasterPage $web.CustomMasterUrl = $NewMasterPage $web.MasterUrl = $NewMasterPage $web.Update() Write-Host "...done." $url = "http://MySharePointSrv.com/teams/IT" $Scollection = "/teams/IT" $NewMasterPage = "$Scollection/_catalogs/masterpage/custom.master" $web = Get-SPWeb $url Write-Host $NewMasterPage $web.CustomMasterUrl = $NewMasterPage $web.MasterUrl = $NewMasterPage $web.Update() Write-Host "...done." $url = "http://MySharePointSrv.com/sites/sitecol1" $Scollection = "/sites/sitecol1" $NewMasterPage = "$Scollection/_catalogs/masterpage/custom.master" $web = Get-SPWeb $url Write-Host $NewMasterPage $web.CustomMasterUrl = $NewMasterPage $web.MasterUrl = $NewMasterPage $web.Update() Write-Host "...done." $url = "http://MySharePointSrv.com/sites/sitecol1/template" $Scollection = "/sites/sitecol1" $NewMasterPage = "$Scollection/_catalogs/masterpage/custom.master" $web = Get-SPWeb $url Write-Host $NewMasterPage $web.CustomMasterUrl = $NewMasterPage $web.MasterUrl = $NewMasterPage $web.Update() Write-Host "...done."
- Remove site columns
# Set Variables
$url = "http://cthub.MySharePointSrv.com"
$siteColumnsList = "myField" # Specify a list of Site Column Names to be deleted, seperated by ;
$site = new-object Microsoft.SharePoint.SPSite($url)
$array = $siteColumnsList.Split(";")
$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 "deleted successfully."
}
catch [System.Exception]
{
Write-Host $column.Title "deleted failed."
#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/
|
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) |
Steps to format a SP2013 site differently depending on the device
This week I was doing some research on how to design to use the new Sharepoint 2013 “device channels” feature which allows designers to show a different MasterPage per device (link), as opposed to just enabling a unique mobile format for all devices.
How to make this
looks like that
took me a good part of the day !
I found a bit of help in various places and will say that JussionSharepoint probably has the most comprehensive steps however he doesn’t discuss designing the Master Page and Layout Page in HTML which is now the recommended way in SP2013, Sonja’s Sharepoint2013 blog also has some valuable reading, but because my brain tends to think in a bullet list kind-of-way so here are my quisksteps on the subject.
[warning] I was going to describe all the steps to configure so that you can navigate your site with a mobile device. However while I was doing so I couldn’t figure out why it still didn’t work on the homepage of my 2013 environment. So here are the pre-requisite before attempting any design. [/warning]
Pre-requisites
1- only works with Publishing Feature enabled
2- only works with Mobile Brower View Feature disabled (otherwise it takes over)
3- finally (this one too me even longer to figure out!) only works if Wiki Page Home Page feature is disabled.
So now that we got that figured out, we can proceed to the customisations.
My 5 or 6 Steps
I said Optionally for step 6, because there is not point creating a LayoutPage just for a certain device unless you are designing a site specific for a device OR you are going to create a page for each device.
Now open the site in Chrome or IE9 and you can change the user-agent so that it simulates you browsing from a mobile device. My preference at the moment is “User-agent Switcher for Chrome”.
Other tips to share
A few things I experienced that I would place in the “good to know” :
– rename the alternative MasterPage for a channel and it will break all channel (ie I renamed the masterpage for iPhone only, the home page errored when opening it using the defaut channel (IE or Chrome), until you edit the MasterPage settings and fix the missing MasterPage for that channel you renamed.
– after I edited the HTML of the Master page a few times, for no reason there was a large blank space that would be added between some DIV elements, even though they were not showing in the code. I had to remove the .master, it will get re-created form the .html within the same second but fixing the blank lines.
Conclusion
Now I have to say I am not impressed… Basically it would be great to build a LayoutPage for each device so that when you load the page one device A it will be LayoutPage A that opens. This way the webpart zone that have been defined horizontally for computer devices could be changed vertically for phone devices.
But that’s not the way it works, because each webpage uses a LayoutPage and that one is not dependant on the channel. The Master Page is the one that depends on the channel however MasterPage do not hold Webpart Zones but the Content Place Holder for the Layout Page.
Therefore there is still some good design work to do if you want to have a full any-devices-friendly sharepoint site.
In the meantime I will play more with the Mobile Browser View features that turns a site into mobile as it may just be the answer.
Of course it will not be adapted to all devices, and what would be nice is to use this feature “most of the time” and for a couple of page to create a layout that uses our special channel Master Page, but since both cannot co-exist it’s a no go for now.
via François on Sharepoint http://sharepointfrancois.wordpress.com/2012/11/27/steps-to-format-a-sp2013-site-differently-depending-on-the-device/
|
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) |
Add the SharePoint Version Number to a Word Document
A client asked me today how he could insert the Version of a file stored in a Sharepoitn Library into a word 2010 document, my initial response was “use Quick Parts” but I tested and to my surprise it’s not showing in the list of QuickParts.
Nor in the column value “[Version]” can be used in a different column: the value is being saved only after the item is processed and therefore any calculated value will not take the change and display 0.
Thanks to those simple no-code steps by CodebyCody it’s a quick fix which gets you to start using Sharepoint Information Management Policy Settings. Enabling this label at a Content Type level for instance “Document” will fix all document library in one shot.
via François on Sharepoint http://sharepointfrancois.wordpress.com/2012/11/21/add-the-sharepoint-version-number-to-a-word-document/
|
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) |
Quick Powershell to delete all items in my Sharepoint list
A quick post with a simple script I gathered a while back that comes in handy for data cleansing before releasing a site:
– how to delete the 100s of items in my list without doing it from the web interface (limited to the maximum displayed in a view)
Use the #powershell script below.
Warning: do this at your own risk, don’t get the wrong site/list or you will regret it
<strong>
</strong> # script starts here…</div>
<div>[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”) | out-null
$oContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;
[Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.WebApplications;
$siteUrl = “http://SharepointSite”
$webName = “”
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
$spList = $spWeb.Lists["List Name"]
foreach ($item in $spList.items)
{
$deaditem=$splist.GetItemById($item.ID)
$deaditem.Delete()
}</div>
<div>
via François on Sharepoint http://sharepointfrancois.wordpress.com/2012/10/31/quick-powershell-to-delete-all-items-in-my-sharepoint-list/
|
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) |








You must be logged in to post a comment.