Kashif Nizam Qureshi

Update Projects Sites’ Write Security Option Through PowerShell

Leave a comment

Following will iterate over all the sites within the specified site collection and updates specified lists’ write security.

#Change these variables to your site URL and list name

$site = Get-SPSite http://dhldepmweb01/PWA

$listName1 = "Assumptions and Constraints"

$listName2 = "Risks"

$listName3 = "Issues"

$listName4 = "Projects Dependent On This Project"

$listName5 = "Projects On Which This Project Depends"

#Walk through each site in the site collection

$site | Get-SPWeb -limit all| ForEach-Object {

write-output("")

#$_.Title

if(!($_.Title.ToLower().Contains("template") -or $_.URL.ToLower().Contains("template")) -And !($_.Title.ToLower().Contains("Business Intelligence Center") -or $_.URL.ToLower().Contains("Business Intelligence Center")))

{

write-output("Checking site:"+$_.Title + " URL: "+$_.URL)

#Get the list in this site

$list1 = $_.Lists[$listName1]

$list2 = $_.Lists[$listName2]

$list3 = $_.Lists[$listName3]

$list4 = $_.Lists[$listName4]

$list5 = $_.Lists[$listName5]

if($list1.WriteSecurity -eq 1 -Or $list2.WriteSecurity -eq 1 -Or $list3.WriteSecurity -eq 1 -Or $list4.WriteSecurity -eq 1)

{

#$_.URL

#Either of the following would work

write-output($list1.Title+": "+ $list1.WriteSecurity)

$list2.Title+": "+ $list2.WriteSecurity

$list3.Title+": "+ $list3.WriteSecurity

$list4.Title+": "+ $list4.WriteSecurity

$list5.Title+": "+ $list5.WriteSecurity

#write-output("about to update")

#Make the list changes

$list1.WriteSecurity = 2

$list2.WriteSecurity = 2

$list3.WriteSecurity = 2

$list4.WriteSecurity = 2

$list5.WriteSecurity = 2

#Update the list

$list1.Update()

$list2.Update()

$list3.Update()

$list4.Update()

$list5.Update()

#write-output("Site updated")

write-output("Site Updated")

}

Else

{

#write-output("Site already updated")

}

}

Else

{

write-output("Template or Explicitly defined Site not updated: "+$_.Title +" URL:"+$_.URL)

}

}

#Dispose of the site object

$site.Dispose()
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s