Steps:
  1. #Get site and web object
  2. $site = Get-SPSite -Identity "http://gauti.sharepoint.com"
  3. $web = $site.RootWeb
  4. #Assign fieldXML variable with XML string for site column
  5. $fieldXML = '<Field Type="DateTime"
  6. Name="DateColumn"
  7. Description="Site Column created by using Powershell with format of date column."
  8. DisplayName="Date Column"
  9. StaticName="DateColumn"
  10. Group="Test Site Columns"
  11. Hidden="FALSE"
  12. Required="FALSE"
  13. Sealed="FALSE"
  14. ShowInDisplayForm="TRUE"
  15. ShowInEditForm="TRUE"
  16. ShowInListSettings="TRUE"
  17. ShowInNewForm="TRUE"></Field>'
  18. #Output XML to console
  19. write-host $fieldXML
  20. #Create site column from XML string
  21. $web.Fields.AddFieldAsXml($fieldXML)
  22. #Dispose of Web and Site objects
  23. $web.Dispose()
Run the script and check the sharepoint site column created successfully.