hi,
i have a column called BU in my splist in many site collections.i had created using with lookup datatype and now since my design is changed i want to create this as a a choice field with few default values. Can anyone please help how to check this using powershell? i mean check the datatype of column using PS and if its lookup then need to delete the list and recreate it with choice field. i know hot to create a splist with choice field using PS, but i am unable to get the code for existence of lookup or choice field.
$web = Get-SPWeb "http://sitename" $fieldnamebu= "BU" $mysplist = $web.lists["mysplist1"] $lookupfieldA="Lookup" foreach($sfield in $mysplist.fields) { # how to check the datatype pf column as lookup if ( ##todo#### -eq $lookupfieldA ) { $mysplist.Delete(); $web.upate();
# create the splist with choice field
$spTemplate = $web.ListTemplates["Custom List"]
#Create SPTemplate instance of Type Custom List
$web.Lists.Add("mysplist1", "for approvers", $spTemplate) #Add list to site$spList = $spWeb.Lists["mysplist1"] #Get list instance
$spList.OnQuickLaunch = $True$spList.Update() #Update list to reflect changes in site
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text #Get Field type to create
$spList.Fields.Add("Mymn", $spFieldType, $false) #Add new field to list} }