Thursday, 31 January 2013

List Page Layout Properties


function LoadSharePointPowerShellEnviroment
{
                write-host
                write-host "Setting up Powershell enviroment for Sharepoint" -foregroundcolor Blue
                Add-PSSnapin "Microsoft.Sharepoint.PowerShell" -ErrorAction SilentlyContinue
                Write-host "Sharepoint PowerShell Snapin loaded." -foregroundcolor Green
}
LoadSharePointPowerShellEnviroment

$site = new-object Microsoft.SharePoint.SPSite("http://ssrap7:88")
$spWeb = $site.OpenWeb("ETSforSuccess")
$spFile = $spWeb.GetFile("Pages/default.aspx")
             

$i = 0

foreach($key in $spFile.Properties.Keys)
{
    write-host $i "File Key: " $key
    $i +=1
}

$i = 0
foreach($val in $spFile.Properties.Values)
{
    write-host $i "File value: " $val
     $i +=1
}

Get Status GUID

When dealing with workflows certain columns must be referenced via their GUID, this is a quick Powershell script to do just that

function LoadSharePointPowerShellEnviroment
{
write-host
write-host "Setting up Powershell enviroment for Sharepoint" -foregroundcolor Blue
Add-PSSnapin "Microsoft.Sharepoint.PowerShell" -ErrorAction SilentlyContinue
Write-host "Sharepoint PowerShell Snapin loaded." -foregroundcolor Green
}

write-host
LoadSharePointPowerShellEnviroment

$site = Get-SPSite ["http://YourUrl:80"]

$web = $site.rootweb
$pages = $web.lists["Item Approval Task"]
$statusField = $pages.Fields["Status"]

write-host $statusField.id