How to Add a Field to a List in PowerShell

[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
#This will get the site URL
$siteUrl = “http://abcd/teams/xxxx”
#This is to get the WebApp
$webName = “abcd”
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
#Trying to find List DEF
$spList = $spWeb.Lists[“DEF”]
Write-Host “$spWeb”
$spList = $spWeb.Lists[“RFC”]
Write-Host “$spList”
{list found}
#RFC List found
$spList.Fields.Add(“Test1″,”Text”,0)
#Column Created
{Field created}
{Script Over}

Advertisements