powershellsitecoresitecore8.2

How to get general link field properties in Sitecore Powershell Extensions


Using SPE (Sitecore Powershell Extensions) I need an Item's general link type field "Url" property, but have been running into problems converting the type.

I've tried to convert Item property to Linkfield object like this:

[Sitecore.Data.Fields.LinkField]$field = $myolditem["Email"]

Output:

Error converting string to Linkfield

How do I convert the string value of the field to a Linkfield type using SPE?


Solution

  • Try using

    [Sitecore.Data.Fields.LinkField]$field = $myolditem.Fields["Email"]
    $Url = $field.Url
    

    You should get the Url of the Link