Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

What I want to do is with a Powershell script programatically go through all subsites in a site collection and change a column name in a list from "Web" to "Site".

So in easier words: Go through subsites 1 2 3 4 5 6... Change a column name "Web" in a list to "Site".

Any help would be much appreciated!

share|improve this question
add comment

1 Answer 1

Have you tried something like this?

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} 

if ($snapin -eq $null) 
{    
    Write-Host "Loading SharePoint Powershell Snapin"    
    Add-PSSnapin "Microsoft.SharePoint.Powershell"  -EA SilentlyContinue
}

$site = Get-SPSite http://portal

foreach ($web in $site.AllWebs)
{
    $lists = $web.Lists

    foreach ($list in $lists)
    {
        foreach ($column in $list.Fields)
        {
            if ($column.Title -eq "Web")
            {
                $web.AllowUnsafeUpdates = $true
                Write-Host "Before change: " $web.Title
                $web.Title = "Site"
                $web.Update()
                Write-Host " After change: " $web.Title
                $web.AllowUnsafeUpdates = $false
                $web.Dispose()
            }
        }
    }
}

$site.Dispose()
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.