Guest User

Untitled

a guest
Jan 25th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. $User = "admin@****.onmicrosoft.com"
  2. $SiteURL = "https://***.sharepoint.com/sites/**** #enter site collection url"
  3.  
  4.  
  5. #Add references to SharePoint client assemblies and authenticate to Office 365 site – required for CSOM
  6. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.dll"
  7. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  8. $Password = Read-Host -Prompt "enterpassword" -AsSecureString
  9. $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
  10.  
  11. #Bind to site collection
  12. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
  13. $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
  14. $Context.Credentials = $Creds
  15.  
  16. $fieldTitle = "AutomaticallyCreated"
  17. $customfield = $Context.Site.RootWeb.Fields.GetByInternalNameOrTitle($fieldTitle)
  18. $customfield.ShowInEditForm($true)
  19. $customfield.ShowInDisplayForm($true)
  20. $customfield.UpdateAndPushChanges($true)
  21.  
  22. $Context.ExecuteQuery()
  23.  
  24. Method invocation failed because [Microsoft.SharePoint.Client.Field] doesn't
  25. contain a method named 'ShowInEditForm'.
  26. At line:1 char:1
  27. + $customfield.ShowInEditForm($true)
  28. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. + CategoryInfo : InvalidOperation: (:) [], RuntimeException
  30. + FullyQualifiedErrorId : MethodNotFound
  31.  
  32. Method invocation failed because [Microsoft.SharePoint.Client.Field] doesn't
  33. contain a method named 'ShowInDisplayForm'.
  34. At line:1 char:1
  35. + $customfield.ShowInDisplayForm($true)
  36. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. + CategoryInfo : InvalidOperation: (:) [], RuntimeException
  38. + FullyQualifiedErrorId : MethodNotFound
Add Comment
Please, Sign In to add comment