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

Update a Date Time Property Via Powershell for Sharepoint Online

$
0
0

Hello.

Via Powershell, I have created a DateTime field with the SchemaXML below.  It shows the Date and Time on the Field (EventEndDate).   This is exactly what I wanted and I have no problems with this Schema,

$FieldSchema = "<Field Type='DateTime' DisplayName='EventEndDate' Required='FALSE' EnforceUniqueValues='FALSE' Indexed='FALSE'Format='DateTime' FriendlyDisplayFormat='Disabled' StaticName='EventEndDate' ShowInEditForm='TRUE' ShowInNewForm='TRUE' Name='EventEndDate'> </Field>"

My problem is that I have a field called "Event Date", which was previously created to show the Date only (which was the requirement at the time).  I now need that field ("Event Date") to show the "Date and Time".   I have tried to update the "Event Date" to now reflect the "Date and Time" in Powershell (code below), but there doesn't appear to be a valid property to change (for SharePoint Online) and it keeps giving me an invalid cmdlet error.

        #Update the field format (Event Date)
        $field = $list.Fields.GetByInternalNameOrTitle("Event_x0020_Date")
        $field.Format = "DateTime"                        ###this option didn't work
        #$field.DisplayFormat = "DateTime"              ###this option didn't work
        $field.Update()
        $list.Update()
        $context.Load($field)
        $context.Load($list)
        $context.ExecuteQuery()

Any ideas on how I can UPDATE this field (Event Date) to show the Date and Time?

Side note:  It does look like this property can be set with SharePoint on-premise, but we are using SharePoint Online.

Thank you.
Harris


Viewing all articles
Browse latest Browse all 7589

Trending Articles



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