-1

I have yes/no type column with default value is "Yes in Pages library.

using PowerShell script I have to change the column default value to No

I have 10 pages exist in Pages library.

Suggest some script

closed as too broad by Robert Lindgren, Gautam Sheth, Mohamed El-Qassas MVP Jun 9 '17 at 12:05

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

4

There are so many links available on the internet, so far the best solution is MSDN article here:

SharePoint: A Complete Guide to Getting and Setting Fields using PowerShell

Though this is MSDN article link, look below for the code example:

$SPAssignment = Start-SPAssignment
$SPWeb = Get-SPWeb http://SP -AssignmentCollection $spAssignment
$SPList = $SPWeb.Lists["MyList"]
$SPItem = $SPList.GetItemById("1")
$SPItem = $SPList.Items | Where { $_["Title"] -eq "Item 1" }
$SPItem["yesnofield"] = $false;  
$SPItem.Update()
Stop-SPAssignment $SPAssignment
  • 1
    While link may answer the question, but still it is important to include essential part of the link in answer, because once the link is broken, the answer become useless.. Cheers !! – Trimantra Software Solution Jun 9 '17 at 9:25
4
#Load the SharePoint Snapin.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
##

##
Write-Host -BackgroundColor Black -f White "Type in web url (ex. http://SITEURL): " -NoNewline 
$webURL = Read-Host
Write-Host -BackgroundColor Black -f White "Type in list display name (ex. Site Pages, Pages): " -NoNewline 
$listName = Read-Host
Write-Host -BackgroundColor Black -f White "Yes/no type column name: " -NoNewline 
$columnName = Read-Host

$web = Get-SPWeb $webURL
$list = $web.Lists[$listName]

foreach ($item in $list.Items)
{
    if( $item[$columnName]  -eq $true)
    { 
        $item[$columnName] = $false
        Write-Host "On page:"  $item.DisplayName " column:" $columnName " is set to:" $item[$columnName] -ForegroundColor Cyan
        #Update item#
        #$item.Update();
    }
}
##

Remove # on $item.Update(); to update items

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