Param ( [string] $SiteUrl = $null ) write-host "Adding Snapin" Add-PsSnapin Microsoft.SharePoint.PowerShell write-host "Added" $BusinessListName = "BusinessList" $ConfigListName = "Config" try { $spweb = Get-SPWeb $SiteUrl $ListGUID = "" $ListUrl = "Lists/{0}" Write-Host "Creating and Configuring SPListDataSource" $ds = New-Object -TypeName Microsoft.SharePoint.SPListDataSource $ListCollection = $spweb.Lists $ds.SetProperty("LobSystemInstance", "db") $ds.SetProperty("EntityNamespace", "Business") $ds.SetProperty("Entity", "BusinessList") $ds.SetProperty("SpecificFinder", "GetBusinessListRead Item") Write-Host "Checking for list instance existence" $list = $spweb.Lists[$BusinessListName]; if($list) { Write-Host "List exists - " + $BusinessListName + " - deleting the list" $list.Delete(); } Write-Host "Creating " + $BusinessListName + " list with Data Source.." $ListGUID = $spweb.Lists.Add($BusinessListName, "", [String]::Format($ListUrl, $BusinessListName), $ds) $ListCollection[$ListGUID].Update(); $spweb.Update(); Write-Host "List created successfully.." + $list = $spweb.Lists[$ConfigListName]; if($list) { Write-Host "List exists - Config - deleting the list" $list.Delete(); }
Thursday, June 14, 2012
Create external list with powershell
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment