$listName="A"
$siteURL="http://serverName:1111"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$list=$web.Lists[$listName]
$rootFolder = $list.RootFolder
$wikiPage = $rootFolder.Files.Add("/"+$rootFolder+"/Home.aspx", [Microsoft.SharePoint.SPTemplateFileType]::WikiPage)
$wikiItem = $wikiPage.Item
$wikiItem[[Microsoft.SharePoint.SPBuiltInFieldId]::WikiField] = "Template Preview"
$wikiItem.UpdateOverwriteVersion()
How to add wiki page to the wiki page library in SharePoint using powershell
In this blog we will be seeing how to add wiki page to the wiki page library in SharePoint using powershell


sandeep singhPosted Aug 22, 2014, 12:17 AM EDT
Script is identical to yours only the Listname="SitePages" and URL="http://wfetest/sites/labteam" differs. SharePoint cmdlets are loaded. Any suggestions. You cannot call a method on a null-valued expression. At line:8 char:36 + $wikiPage = $rootFolder.Files.Add <<<< ("/"+$rootFolder+"/Home1.aspx", [Microsoft.SharePoint.SPTemplateFileType]::WikiPage) + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Cannot index into a null array. At line:10 char:13 + $wikiItem[ <<<< [Microsoft.SharePoint.SPBuiltInFieldId]::WikiField] = "Template Preview" + CategoryInfo : InvalidOperation: (c33527b4-d920-4587-b791-45024d00068a:Guid) [], RuntimeException + FullyQualifiedErrorId : NullArray You cannot call a method on a null-valued expression. At line:11 char:35 + $wikiItem.UpdateOverwriteVersion <<<< () + CategoryInfo : InvalidOperation: (UpdateOverwriteVersion:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
Adam CarlsonPosted Feb 29, 2012, 12:42 PM EST
Script is identical to yours only the Listname="Document Wiki" and URL="http://wfetest/sites/labteam" differs. SharePoint cmdlets are loaded. Any suggestions. You cannot call a method on a null-valued expression. At line:8 char:36 + $wikiPage = $rootFolder.Files.Add <<<< ("/"+$rootFolder+"/Home1.aspx", [Microsoft.SharePoint.SPTemplateFileType]::WikiPage) + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Cannot index into a null array. At line:10 char:13 + $wikiItem[ <<<< [Microsoft.SharePoint.SPBuiltInFieldId]::WikiField] = "Template Preview" + CategoryInfo : InvalidOperation: (c33527b4-d920-4587-b791-45024d00068a:Guid) [], RuntimeException + FullyQualifiedErrorId : NullArray You cannot call a method on a null-valued expression. At line:11 char:35 + $wikiItem.UpdateOverwriteVersion <<<< () + CategoryInfo : InvalidOperation: (UpdateOverwriteVersion:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull