Quantcast
Viewing latest article 3
Browse Latest Browse All 5

Update Site Default Page(Welcome Page) Content Type with PowerShell

This is a script that you can use to update a content type of your default page. With a little modification you can use bits of this script to update any page or list item content type.

param(
[string]$url
)

Start-Transcript -Path “output.log” -Append -Force -Confirm:$false

if (-not $url)
{
Write-Host “Specify site url in url parameter” -foregroundcolor red
return
}
Write-Host “##################################################” -foregroundcolor White
Install-SPFeature -Path “feature name”
Write-Host “Feature was sucessfully installed” -foregroundcolor green
Enable-SPFeature -Identity “feature name” -Url $url
Write-Host “Feature was sucessfully activated on” $url “site” -foregroundcolor green

Write-Host “##################################################” -foregroundcolor White

Write-Host “Opening Root Site” $url -foregroundcolor green

$web = Get-SPWeb $url
Write-Host “Retrieving default Page” -foregroundcolor yellow
$welcomePage = $web.GetListItem($web.RootFolder.WelcomePage)
Write-Host “Assigning the new content type to the default Page” -foregroundcolor yellow
$welcomePage["ContentTypeId"] = $welcomePage.ParentList.ContentTypes["new content type name"].Id
Write-Host “Updating the default Page” -foregroundcolor yellow
$welcomePage.SystemUpdate()
Write-Host “Update finished to the default Page” -foregroundcolor green
Write-Host “##################################################” -foregroundcolor White
Stop-Transcript


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 3
Browse Latest Browse All 5

Trending Articles