Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #Load SharePoint CSOM Assemblies
  2. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
  3. Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"
  4.    
  5. #Config Parameters
  6. $SiteURL= "SITEURL"
  7. $ListName="TestBest1"
  8. $FieldName = "DocumentImportStatus" #Display Name
  9.  
  10. #Setup Credentials to connect
  11. $Cred = Get-Credential
  12. $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
  13.  
  14. Try {
  15.     #Setup the context
  16.     $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
  17.     $Ctx.Credentials = $Cred
  18.    
  19.     #Get the web, List and Field objects
  20.     $Web=$Ctx.Web
  21.     $List=$web.Lists.GetByTitle($ListName)
  22.     $Field = $List.Fields.GetByTitle($FieldName)
  23.  
  24.     #Hide the column from New & Edit forms
  25.     $Field.SetShowInEditForm($False)
  26.     $Field.SetShowInNewForm($False)
  27.     $Field.UpdateAndPushChanges($True)
  28.     $Ctx.ExecuteQuery()
  29.       
  30.     Write-host -f Green "List Field hidden Successfully!"
  31. }
  32. Catch {
  33.     write-host -f Red "Error hiding List Column: " $_.Exception.Message
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement