Upload publishing page, checkin, approve

22/03/2012 12:58

#Dummy approved Content for Search, one category card and one faq.

#input parameters
$srcPath="C:\users\gbpinstall\desktop"
$siteUrl="https://td_sp_ui/gbp/portal"
$ccFileName="aaa.aspx"
$faqFileName="question-doc2.aspx"


function UploadFile
{
    param([string]$srcPath,
            [string]$fileName,
            [string]$subsiteUrl)
           
  $web=get-spweb $subsiteUrl
  $folder=$web.GetFolder("Pages")         
  $file=get-childitem ($srcPath + "\" + $fileName)
  $files=$folder.Files
  $files.Add(($subsiteUrl+"/Pages/" + $fileName), $file.OpenRead(), $true)
  $files[$fileName].checkIn("checked in by Powershell")
  $files[$fileName].publish("published by Powershell")
  start-sleep -s 5
  $files[$fileName].Item.File.Approve("Approved by Powershell")
  $web.dispose()
           
}


UploadFile -srcPath $srcPath -fileName $faqFileName -subsiteUrl ($siteUrl +"/helpdesk/faq")
#UploadFile -srcPath $srcPath -fileName $ccFileName -subsiteUrl ($siteUrl +"/CategoryCards")