Guest User

Untitled

a guest
Dec 4th, 2017
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Add-Type -Path (Resolve-Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll")
  2. Add-Type -Path (Resolve-Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll")
  3.  
  4. Function Get-SPOContext([string]$Url,[string]$UserName,$Password)
  5. {
  6. write-host Get-SPOContext
  7. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
  8. $Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password) #SecurePassword
  9. return $Context
  10. }
  11.  
  12. $UserName = "lee@xxx.onmicrosoft.com"
  13. $Password = Read-Host -Prompt "Enter password" -AsSecureString
  14. $Url = "https://xxx.sharepoint.com/sites/Developer"
  15. $listTitle="MyList"
  16. $FieldName="Comment"
  17.  
  18. $Context = Get-SPOContext -Url $Url -UserName $UserName -Password $Password
  19. $List = $Context.Web.Lists.GetByTitle($ListTitle)
  20. $Context.Load($List)
  21. $Context.ExecuteQuery()
  22.  
  23. #Retrieve field
  24. $field = $List.Fields.GetByInternalNameOrTitle($FieldName)
  25. $Context.Load($field)
  26. $Context.ExecuteQuery()
  27. $field.SetShowInEditForm($false)
  28. $field.UpdateAndPushChanges($true)
  29.  
  30. $Context.ExecuteQuery()
  31.  
  32. write-host Done
Add Comment
Please, Sign In to add comment