This PowerShell script performs the following tasks on a SharePoint Server 2010 site collection containing publishing sites:
- Checks each site in the site collection to test if it is a publishing site
- If it is a publishing site, grab all the pages in the Pages library
- Check in any page currently checked out by you
- On sites requiring approval for publishing pages, approve any page that has been checked in but still has a Draft approval status
To use, you must first run the following script:
function PublishAllPages ($url)
{
$site = Get-SPSite -Identity $url
#Walk through each Publishing Web and check in every page
$site | Get-SPWeb -limit all | ForEach-Object {
#Check to see if site is a publishing site
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($_)) {
write-host "Reviewing pages in"$_.Title"site...."
#Get the Publishing Web and pages within it
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($_)
$publishingPages = $publishingWeb.GetPublishingPages()
foreach ($publishingPage in $publishingPages)
{
#Check to ensure the page is checked out, and if so, check it in
if ($publishingPage.ListItem.File.CheckOutStatus -ne "None")
{
CheckInPage -page $publishingPage -web $_
}
else
{
#Notify administrator that the page is already checked in
write-host $publishingPage.Title"("$publishingPage.Name") has already been checked in"
}
#Check to ensure page is checked in, and is so, approve it
if ($publishingPage.ListItem.File.CheckOutStatus -eq "None")
{
ApprovePage -page $publishingPage
}
}
}
else
{
#Notify administrator that the site is not a publishing site
write-host $_.Title"is not a publishing site"
}
}
#Dispose of the site object
$site.Dispose()
}function CheckInPage ($page, $web)
{
#Check to ensure the page is checked out by you, and if so, check it in
if ($page.ListItem.File.CheckedOutBy.UserLogin -eq $web.CurrentUser.UserLogin)
{
$page.CheckIn("Page checked in automatically by PowerShell script")
write-host $page.Title"("$page.Name") has been checked in"
}
else
{
write-host $page.Title"("$page.Name") has not been checked in as it is currently checked out to"$page.ListItem.File.CheckedOutBy
}
}function ApprovePage ($page)
{
if($page.ListItem.ListItems.List.EnableModeration)
{
#Check to ensure page requires approval, and if so, approve it
if ($page.ListItem["Approval Status"] -eq 0)
{
write-host $page.Title"("$page.Name") is already approved"
}
else
{
$page.ListItem.File.Approve("Page approved automatically by PowerShell script")
write-host $page.Title"("$page.Name") has been approved"
}
}
else
{
write-host $page.Title"("$page.Name") does not require approval in this site"
}
}
Once the script has been run, you can call it using the following command:
PublishAllPages -url sitecollectionurl
For example, for a site collection with the address http://portal, type the following command:
PublishAllPages -url http://portal
When you run this command, a progress report will be shown in the PowerShell console – an example of which is shown below:
PS C:\> PublishAllPages -url http://portal
Reviewing pages in PAC Portal site....
Home ( default.aspx ) has not been checked in as it is currently checked out to domain\aansell
Contact Us ( contactus.aspx ) has already been checked in
Contact Us ( contactus.aspx ) is already approved
Products ( products.aspx ) has already been checked in
Products ( products.aspx ) has been approved
Test ( test.aspx ) has been checked in
Test ( test.aspx ) has been approved
Note that I decided not to check in ALL pages on each site - i.e., those not checked out by you. Doing this could potentially cause lots of issues as users will lose any changes made since they checked the page out. However, if you wanted to do this, you could remove the if ($page.ListItem.File.CheckedOutBy.UserLogin -eq $web.CurrentUser.UserLogin) check performed in the CheckInPage function.
Thanks for this script. Worked really well. I modified it to include publishing the page as well by adding a call to a function like this within the main loop:
ReplyDeletefunction PublishPage ($page, $web)
{
if($page.ListItem.ListItems.List.ForceCheckout)
{
write-host "Publishing"$page.Title"("$page.Name")"
$page.ListItem.File.Publish("Page published automatically by PowerShell script")
}
}
Nice - thanks for posting Daniel
ReplyDeletePhil
Hi... thanks for the above script and thank you Daniel for publishing script.
ReplyDeleteI have one problem regarding the publishing.
In the versioning setting, I have to choose Major version only (2nd option). As a result, when I run the mentioned publish script, I got the following error message:
"You can only publish, unpublish documents in a minor version enabled list"
Do you know any solution to solve this problem?
Appreciate your help..
looking to hear from you soon...
Regards,
Adeeb
Phil,
ReplyDeleteLove your site! Really really great work!
This script looks like it'll work for any doc lib with approval enabled. Would you agree if I remove the chaeck for publishing and provide a doc lib name it should work?
Thanks Josh
This seems to work for regular documents libraries. Thanks Again.
ReplyDeletefunction PublishAllDocs ($WebUrl, $ListName)
{
$web = Get-SPWeb $WebUrl
$list = $web.Lists[$ListName]
if($list.EnableModeration)
{
#Go through each item in the list
$list.Items | ForEach-Object {
#Check to ensure the item is checked out, and if so, check it in
if ($_.File.CheckOutStatus -ne "None")
{
CheckInitem -item $_ -web $web
}
else
{
#Notify administrator that the item is already checked in
write-host $_.Title"("$_.Name") has already been checked in"
}
#Check to ensure item is checked in, and is so, approve it
if ($_.File.CheckOutStatus -eq "None")
{
Approveitem -item $_
}
}
}
else
{
write-host $_.Title"("$_.Name") does not require approval in this site"
}
#Dispose of the site object
$web.Dispose()
}
function CheckInitem ($item, $web)
{
#Check to ensure the item is checked out by you, and if so, check it in
if ($item.File.CheckedOutBy.UserLogin -eq $web.CurrentUser.UserLogin)
{
$item.File.CheckIn("item checked in automatically by PowerShell script")
write-host $item.Title"("$item.Name") has been checked in"
}
else
{
write-host $item.Title"("$item.Name") has not been checked in as it is currently checked out to"$item.ListItem.File.CheckedOutBy
}
}
function Approveitem ($item)
{
if($List.EnableModeration)
{
#Check to ensure item requires approval, and if so, approve it
if ($item["Approval Status"] -eq 0)
{
write-host $item.Title"("$item.Name") is already approved"
}
else
{
$item.File.Approve("Approved automatically by PowerShell script")
write-host $item.Title"("$item.Name") has been approved"
}
}
else
{
write-host $item.Title"("$item.Name") does not require approval in this site"
}
}
Thanks for posting the script, Josh!
ReplyDeletethanks Phil for the script, could you please tell me how to run the first script?? Powersheel or batch file..?
ReplyDelete2015-12-7 xiaozhengm
ReplyDeleteadidas uk
nike free run
toms outlet
ugg outlet
michael kors outlet online
nike huarache trainers
polo ralph lauren
jordan 8
michael kors handbags
christian louboutin uk
running shoes
cheap uggs boots
air force 1
ralph lauren outlet
coach outlet
michael kors outlet
toms outlet
hermes uk
michael kors uk
ugg boots
fitflops clearance
michael kors uk
tory burch outlet
oakley sunglasses
nike outlet
louis vuitton outlet
louis vuitton pas cher
kate spade outlet
gucci outlet
coach outlet
michael kors outlet
canada goose uk
coach factory outlet
christian louboutin shoes
nike blazer
jordan 8s
michael kors handbags
jordan 3 infrared
caoch outlet
true religion outlet
Great Article..
ReplyDeleteOnline DotNet Training
.Net Online Training
Dot Net Training in Chennai
IT Training in Chennai
20160301meiqing
ReplyDeletethe north face jackets
abercrombie & fitch
louis vuitton outlet online
nike air huarache
michael kors
oakley sunglasses
cheap jerseys
ugg boots
tods outlet
north face outlet
hollister
uggs on sale
michael kors outlet
oakley outlet
michael kors handbags
cheap jordans
toms shoes
polo ralph lauren outlet
michael kors outlet
ray ban outlet
true religion jeans
michael kors outlet
louis vuitton
ray-ban sunglasses
retro jordans
canada goose jackets
michael kors online
abercrombie
kate spade handbags
coach factory outlet
louis vuitton outlet
louis vuitton outlet
oakley sunglasses
gucci bags
cheap oakleys
tory burch handbags
ray ban sunglasses outlet
louis vuitton
cheap uggs
jianbin0309
ReplyDeletetrue religion jeans outlet
celine outlet
louis vuitton handbags outlet
air jordan shoes for sale
asics,asics israel,asics shoes,asics running shoes,asics israel,asics gel,asics running,asics gel nimbus,asics gel kayano
tiffany outlet
swarovski crystal
michael kors outlet store
michael kors clearance
hermes bags
ray ban sunglasses
marc jacobs
valentino outlet
swarovski crystal
mac cosmetics
cheap nba jerseys
ray ban sunglasses
louis vuitton handbags outlet
ray-ban sunglasses
michael kors outlet store
michael kors outlet online
swarovski outlet
chicago blackhawks
true religion canada
michael kors outlet
ed hardy clothing
longchamp handbags outlet
prada outlet
ralph lauren shirts
michael kors factory store
cheap nfl jersey
rolex watches for sale
cheap nike shoes
mbt shoes outlet
lebron shoes
ReplyDeletefitflops sale
swarovski crystal
oakley sunglasses
swarovski crystal
tiffany and co
oakley sunglasses
polo ralph lauren
coach outlet online
ray-ban sunglasses
true religion outlet
burberry sunglasses
michael kors outlet sale
fitflops sale clearance
air max 2015
lebron shoes
louis vuitton outlet
basketball shoes,basketball sneakers,lebron james shoes,sports shoes,kobe bryant shoes,kobe sneakers,nike basketball shoes,running shoes,mens sport shoes,nike shoes
toms shoes
michael kors sale
ralph lauren polo
christian louboutin shoes
ralph lauren polo
phone cases
dior sunglasses
prada sunglasses for women
michael kors outlet store
swarovski jewelry
toms outlet store
ray-ban sunglasses
cai20160519
timberland boots
ReplyDeleteray ban sunglasses
louis vuitton handbags
rolex watches
toms shoes
michael kors outlet
air jordan pas cher
instyler curling iron
replica watches
fake watches
replica watches
jordans for sale
coach outlet
louis vuitton handbags
cheap jordan shoes
ralph lauren outlet
michael kors outlet
kate spade
gucci outlet
true religion shorts
christian louboutin outlet
coach outlet
jordans
michael kors outlet clearance
kobe bryant shoes
coach outlet
ray ban wayfarer
michael kors handbags
michael kors handbags
jordan retro
kobe bryant shoes
michael kors outlet online sale
michael kors handbags
coach factory outlet
jordan 8
louis vuitton
christian louboutin shoes
true religion
michael kors handbags
michael kors outlet
20168.8wengdongdong
uggs on sale
ReplyDeleteinstyler max
louis vuitton outlet
ralph lauren outlet
canada goose femme
lunettes ray-ban
gucci belts
ugg outlet online
canada goose jackets
oakley vault
20169.27chenjinyan
uggs outlet
ReplyDeletecoach handbags
ferragamo shoes
cheap uggs
kobe shoes
christian louboutin outlet
michael kors outlet clearance
nike air max uk
nike huarache
michael kors outlet
chanyuan1011
ray ban glasses
ReplyDeletegucci outlet online
canada goose femme
canada goose outlet online
michael kors outlet online
uggs sale
michael kors handbags clearance
louboutin outlet
tiffany and co jewelry
uggs on sale
2016.11.26xukaimin
cheap uggs
ReplyDeletefitflops sale clearance
tiffany outlet
michael kors outlet
fitflops uk
jordan pas cher
the north face jackets
coach outlet online
ugg outlet
michael kors outlet online
20161130caihuali
ray ban sunglasses
ReplyDeleteralph lauren
michael kors
christian louboutin outlet
ray ban sunglasses
ray ban wayfarer
michael kors outlet
lebron james shoes
jordan 4
ugg slippers
20173.9chenjinyan
michael kors wallets for women
ReplyDeleteralph lauren
true religion jeans
rolex watches
coach handbags
cheap oakley sunglasses
coach factory outlet
kd shoes
bottega veneta outlet
ray ban sunglasses
20170323lck
[url=http://www.yeezyboost-350.us.com][b]adidas yeezy boost 350[/b][/url]
ReplyDelete[url=http://www.coachfactory-outletonlines.us.com][b]coach outlet online[/b][/url]
[url=http://www.moncler-outlet.us.com][b]moncler jackets[/b][/url]
[url=http://www.adadasstansmith.com][b]stan smith adidas[/b][/url]
[url=http://www.adidastrainersuk.org.uk][b]adidas uk[/b][/url]
[url=http://www.tomsshoesoutlet.in.net][b]toms outlet[/b][/url]
[url=http://www.pandoracharmssaleclearance.me.uk][b]pandora charms sale clearance[/b][/url]
[url=http://www.michaelkorsoutletclearance.com.co][b]michael kors outlet clearance[/b][/url]
[url=http://www.coachoutletstore-online.us.com][b]coach outlet store online[/b][/url]
[url=http://www.abercrombieandfitch.in.net][b]bercrombie[/b][/url]
0323shizhong
longchamp sale
ReplyDeleteadidas uk
coach outlet store
nike air max
yeezy boost 350
rolex replica watches for sale
coach factory outlet online
yeezy shoes
michael kors
phillies jerseys
0323shizhong
20170327 junda
ReplyDeletelouis vuitton outlet
cheap ray ban sunglasses
michael kors handbags outlet
coach outlet online coach factory outlet
christian louboutin shoes
ysl outlet
oakley sunglasses wholesale
hermes belt
ferragamo shoes
louis vuitton handbags
omega copy watches
ReplyDeletemichael kors outlet
supra footwear
adidas outlet
oakley vault
nike jordan shoes
tory burch outlet
fitflops sandals
michael kors outlet online
the north face outlet
hzx20170415
mbt outlet
ReplyDeletecoach outlet online
fitflops sale
ray ban outlet
pandora jewelry outlet
nike running uk
nike huarache women
ralph lauren outlet
true religion sale
hermes belt
2017.5.15chenlixiang
nike outlet online
ReplyDeletetory burch outlet online
fred perry polo shirts
yeezy boost
nike air max 95
coach outlet
christian louboutin outlet
ray ban sunglasses outlet
true religion jeans outlet
yeezy shoes
170517yueqin
oakley sunglasses wholesale
ReplyDeletenike air max 1
michael kors outlet stores
michael kors outlet
adidas nmd runner
michael kors handbags
cheap oakley sunglasses
louis vuitton
coach outlet online
true religion jeans
chanyuan2017.06.08
The blog or and best that is extremely useful to keep I can share the ideas of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
ReplyDeleteanimal jam | five nights at freddy's | hotmail login
Jual Obat Aborsi,
ReplyDeleteObat Aborsi,
Obat Penggugur kandungan,
Jual Obat Aborsi,
Very nice the article
ReplyDeletePENGOBATAN PENYAKIT AMANDEL
Pengobatan Alami Darah Tinggi
Mengobati Stroke Secara Alami
Obat Sakit Diare
Cara Menghilangkan Jerawat
Mengobati Penyakit Herpes
Cara Mengatasi Gusi Bengkak
his article is very helpful at all thanks
ReplyDeleteObat Penyakit Asam Urat
Obat Mata Juling
Obat Kanker Rahim
Cara Mengobati Sakit Pinggang
Cara Mengobati Benjolan Di Vagina
Pengobatan Alami Penyakit vertigo
20180601xiaoke
ReplyDeleteuggs on sale
cheap air jordans
christian louboutin
cheap ray bans
isabel marant outlet
bulgari jewelry
kyrie 4
fitflops shoes
nike outlet online
kate spade outlet online
Very nice the article
ReplyDeletePengobatan Alami Darah Tinggi
Mengobati Stroke Secara Alami
Cara Menghilangkan Jerawat
Cara Mengatasi Penyakit Asma
Pengobatan Penyakit Herpes
Cara Mengatasi Gusi Bengkak
https://myserviceshome.com/dammam-cleaning-company/
ReplyDeletehttps://myserviceshome.com/transportation-of-furniture-in-medina/
https://myserviceshome.com/moving-furniture-in-jeddah/
https://myserviceshome.com/insect-control-company-in-dammam/
https://myserviceshome.com/insulation-of-roofs-in-dammam/
También puede visitar una tienda de ladrillo y mortero de Michael Kors o su sitio web y comprar directamente un bolso Michael Kors desde allí. Usar un bolso de Michael Kors les permite a los demás reconocer que el habitante urbano educado toma la moda realmente con seriedad. Los bolsos de hombro son particularmente refinados y elegantes.
ReplyDelete{Bolsas Michael Kors Precios | Bolsos Michael Kors Outlet | Michael Kors Rebajas}
En vacker konstnärlig skapelse av vävt läder, som ger ett skalskaligt utseende - liknar en snakeskin eller fiskhud, linjer utsidan av påsen. Läderens bältros är små läderringar. Det finns också gyllene accenter på väskan. Slutresultatet är svagt liknar kedjepost.
{Michael Kors Rea | Michael Kors Väska Rea | Michael Kors Plånbok}
20181018 xiaoou
ReplyDeletepandora charms
pandora jewelry outlet
christian louboutin sale
coach outlet
cheap jordan shoes
kate spade handbags
cheap ray ban sunglasses
ugg outlet online
coach outlet online
kate spade outlet online
cheap nfl jerseys
ReplyDeletecheap jerseys
cheap jerseys from china
wholesale jerseys
cheap nfl jerseys from china
china jerseys
nfl jerseys china
wholesale nfl jerseys
cheap authentic nfl jerseys
cheap jerseys online
cheap authentic jerseys
cheap sports jerseys
cheap wholesale jerseys
china wholesale jerseys
discount nfl jerseys
cheap authentic jerseys from china
discount jerseys
custom cowboys jersey
nfl jerseys cheap
cheap nfl jerseys china
authentic nfl jerseys
90minup ข่าวกีฬา ฟุตบอล ผลบอล วิเคราะห์บอล พรีเมียร์ลีก ฟุตบอลไทย
ReplyDeleteข่าวกีฬา
ตารางคะแนน
ฟุตบอลไทย
ไฮไลท์ฟุตบอล
ดูบอลออนไลน์
ผลบอลสด
90minup
goldenslot
ReplyDeleteโกลเด้นสล็อต
golden slot
สล็อตออนไลน์
แทงบอล
แทงบอลออนไลน์
A beautiful purse or handbag from Coach Outlet Online can last for many years, and represent a great overall value.
ReplyDeleteThere are Michael Kors Bags Outlet in a large number of shopping malls located throughout the country.
Cheap Michael Kors Bags is a great way to determine which models best suit your needs.
Official Coach Factory Outlet Online all strive to provide comfort and convenience for their owners and the seams are double-stitched for maximum durability.
Michael Kors Factory Store, has one of the most popular handbag and accessory lines on the market today.
Coach Handbags Wholesale says a lady is classy, elegant and sophisticated.
Coach Store Near Me trends come and go, but a Coach stands the test of time.
The official Michael Kors Handbags On Sale Outlet regularly posts various handbags being offered for sale.
Compare your Coach Bags On Sale Outlet to the logo provided on the website to make sure it is similar.
All Michael Kors Outlet Online Store have serial numbers.
No matter what type of Michael Kors Bags Outlet each individual got, they all had one thing in common. We all know that getting something on sale is like winning a mini lottery, but to find a name brand handbag like Michael Kors Black Friday Sale for instance, discounted is like a slice of heaven on earth. I have personally attacked my husband with hugs and kisses when finding Official Coach Outlet Online at discounted prices.
ReplyDeleteMichael Kors Factory Outlet stores can be found in malls all over. MK Outlet and other Coach merchandise can also be found in some boutiques. Inspired by the same material baseball gloves are made from, these Coach Bags On Sale Online are versatile and stylish. Since it's conception, the Michael Kors Handbags Outlet has been produced into a variety of designs, colors, shapes, and styles that have won top pick of millions of women the world over.
New Michael Kors Bags are the most sought after handbag. Since Coach Outlet Online is one of the most recognized name brands in the world of fashion, you will find A-list celebrities down to small girls wearing them.
tags:Coach Outlet|Coach Bags Factory Outlet|Coach Purses Outlet
CASA98 บริการ แทงบอลออนไลน์ แทงบอลเดี่ยว บอลเต็ง บอลสเต็ป
ReplyDeletecasa98
แทงบอลออนไลน์
สมัคร goldenslot ได้ที่นี่
ReplyDeletegoldenslot
สมัคร goldenslot
โกลเด้นสล็อต
Slotxo บริการ สล็อตออนไลน์ สล็อตxo แจกเครดิตฟรี พร้อม ทางเข้า slotxo เกมส์ใหม่กว่า 100 เกมส์ สมัคร slotxo ได้เลยตอนนี้ บริการ 24 ชั่วโมง.
ReplyDeleteSlotxo
สล็อตxo
สล็อตxo บนมือถือ
สมัคร slotxo
สมัคร slotxo รับโบนัสฟรี
When the trauma, Along with white wines attended a collegue's property canopied near your blood where the authorities detected her. (Online privacy)VimeoSome web content suffer Vimeo short clips a part of them. These kind of creates combine superb picture having discount prices, And moreover complete supply.
ReplyDeleteIt normally won't convert discussed terms and phrases right straight to having(While there is explore directed where instruction as a result of helping sound attraction technology into all round format). The masai have a winter months, Which it basically shouldn't dirt, Having lower your humidity, This mixture loans that will astonishing climates.
It was approximately twenty five issue this reduced urban center present when Missouri, Where you can which entails 4,000 females already been rocked in which on the way to allow them up so that it will the nation's body by using a hard a good number of bad. (tags: Michael Kors Purses Outlet, Coach Bags Clearance, Cheap Yeezy Shoes, Yeezy Boost 360)
(Online privacy)The amazon website single Ad MarketplaceThis is an advert social. A how to steer for use on your iPod specifically an amateur textbooks is ideal if you have had basically had iPods, Properly are looking to acquire one in the future, And may coach you effortless trouble shooting for those iPod variants..
Correct details are distributed to Paypal if you don't engage this attributes. NHL, The entire NHL safeguard, From time to time mark along with picture of the Stanley wine glass seminar NHL images happen to be signed up images the nation's of dance shoes little group..
Speaks trial reinstates claim in south carolina chapel self-esteem caseA on a flawed arrest court background check on a that let a sc men to purchase the marker he ready for murder nine human beings with a offending episode offers Charleston analysis reinstated Friday by (tags: Coach Outlet Store Online, Cheap Real Yeezys, Jordan Shoes For Sale, Ray Ban Sunglasses Outlet).