Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

PowerShell script to create Document Library with a hyperlink field

$
0
0

I am working on a PowerShell script to create a new Document Library for a site, however, I need to add a hyperlink field. How would I go about coding that? I think the internal field name is "fileref".

Here is my current code which creates 1 text field.

$webURL=“http://xyz/sites/intranet/abcsite"

$spSite=[Microsoft.SharePoint.SPSite]($webURL)

$spWeb=$spSite.OpenWeb()

# Create a document library (ID is 101)

$myListGuid=$spWeb.Lists.Add(“riskmgmt”,“Risk Management”,101)

$myList=$spweb.Lists[$myListGuid]

#

# Update the List Title

$myListObj=$spWeb.Lists["riskmgmt"]

$myListObj.Title=“Risk Management”

$myListObj.Update()

#

# Adding fields

$myFieldCustomerName=$myList.Fields.Add(“Procedure”,“Text”,0)

$myList.Fields[$myFieldCustomerName].Title=“Procedure Title”

$myList

.Fields[$myFieldCustomerName].Update()

$spWeb.Dispose()

$spSite.Dispose()


If I go into the library settings and manually update the columns I would need to add they hyperlink field which includes the URL and the description. How do I get the same results, but through PowerShell?

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>