Below script for it loops through all of your sites in the server
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
$WebAppUrl = "servername"
$site = new-object Microsoft.SharePoint.SPSite($WebAppUrl)
$web = $site.OpenWeb()
$list = $web.Lists["Projects List"]
$query = new-object Microsoft.SharePoint.SPQuery
$query.Query = "<Where><Eq><FieldRef Name='Status' /><Value Type='Choice'>Success</Value></Eq></Where><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>"
#$query.RowLimit = 2
[xml]$viewfields = "<ViewFields><FieldRef Name='Project_x0020_ID' /><FieldRef Name='Title' /></ViewFields>"
$result = $list.GetItems($query)
#Write-Host $result.count
foreach ($resultItem in $result)
{
$siteURL = $resultItem["SiteURL"]
$oRootsite = new-object Microsoft.SharePoint.SPSite($siteURL)
$RootWeb = $oRootsite.OpenWeb()
$lookForList ="Events"
$EventsList= $RootWeb.Lists[$lookForList]
if ($EventsList -ne $null)
{
$queryEvents = new-object Microsoft.SharePoint.SPQuery
$queryEvents.Query ="<Where><Eq><FieldRef Name='WorkspaceLink' /><Value Type='CrossProjectLink'>1</Value></Eq></Where>"
#[xml]$viewfields = "<ViewFields><FieldRef Name='Project_x0020_ID' /><FieldRef Name='Title' /></ViewFields>"
$Queryresult = $EventsList.GetItems($queryEvents)
Write-Host $siteURL + ":" + $Queryresult.Count
foreach ($eventListItem in $Queryresult)
{
if($eventListItem["WorkspaceLink"] -eq $true)
{
$eventListItem["Workspace"]= $null
$eventListItem.SystemUpdate($false)
Write-Host $eventListItem["Title"] "---" $eventListItem["Workspace"]
}
}
}
# Rollout OPS Project Stages and Update document edit form
# Enable-SPFeature –Identity "be307273-d9de-4f16-84d2-52b5e1467ff0" –url $siteURL
}
for single site
$siteUrl = "http://servername/sites/P127036/"
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$RootWeb = $site.RootWeb
$lookForList ="Events"
$EventsList= $RootWeb.Lists[$lookForList]
if ($EventsList -ne $null)
{
$query = new-object Microsoft.SharePoint.SPQuery
$query.Query ="<OrderBy><FieldRef Name='Title' /></OrderBy>"
#[xml]$viewfields = "<ViewFields><FieldRef Name='Project_x0020_ID' /><FieldRef Name='Title' /></ViewFields>"
$result = $EventsList.GetItems($query)
Write-Host $result.count
foreach ($resultItem in $result)
{
if($resultItem["WorkspaceLink"] -ne $false)
{
Write-Host $resultItem["Title"] "---" $resultItem["Workspace"]
$resultItem["Workspace"]= $null
$resultItem.SystemUpdate()
Write-Host "After updated:" $resultItem["Workspace"]
}
}
}
Tuesday, August 2, 2011
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2011
(49)
-
▼
August
(33)
- Sharepoint 2010: Folder Modified Date doesn't get ...
- Sharepoint 2010: Hide ContentType Field using Powe...
- Sharepoint 2010: Update SPNavigationNode Title
- Sharepoint 2010 : Display All Calendar Workspaces ...
- sharepont 2010:Display thumbnail view of picture l...
- Sharepoint 2010 : Display Thumbnail view for Pictu...
- Redirect from newMWS.aspx page to custom page
- Sharepoint 2010 : Create or Provisioning Custom Ed...
- Sharepoint 2010 : Show dialog box for custom "Add ...
- Sharepoint 2010: show "Add new item" or "Add new"...
- Sharepoint 2010 : Create or Delete View programmat...
- Sharepoint 2010 : Custom ListView WebPart
- Links
- Define Content types in Sharepoint 2010
- Reset ContentType Order in SharePoint 2010
- Remove roles from Sharepoint list item
- Hide Content types in the sub Folders in Sharepoin...
- Add Content types to List or Library in Sharepoint...
- Set Selected Content type in Dropdown in Sharepoin...
- Create Site Collection programmatically in Sharepo...
- Create Documentset programmatically in Sharepoint ...
- Get all Calendar Workspace Events in Sharepoint 2010
- Get Sharepoint Control ID using Javascript in Shar...
- Hide content types from new menu using Javascript ...
- Disable New Menu Button Prompt in Sharepoint 2010
- Create Folder in SharePoint List or Library progra...
- Update folder name of List or Library programmatic...
- Update content type filed in the shareponit 2010 l...
- upgrade sharepoint 2010 wsp using powershell script
- Update Title Sharepoint 2010 List using Powershell...
- Rename Content type name in the list using Powershell
- Update Workspace URL using Powershell
- create custom field Person/ Group in Sharepoint 2010
-
▼
August
(33)
No comments:
Post a Comment