Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -Path (Resolve-Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll")
- Add-Type -Path (Resolve-Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll")
- Function Get-SPOContext([string]$Url,[string]$UserName,$Password)
- {
- write-host Get-SPOContext
- $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
- $Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password) #SecurePassword
- return $Context
- }
- $UserName = "lee@xxx.onmicrosoft.com"
- $Password = Read-Host -Prompt "Enter password" -AsSecureString
- $Url = "https://xxx.sharepoint.com/sites/Developer"
- $listTitle="MyList"
- $FieldName="Comment"
- $Context = Get-SPOContext -Url $Url -UserName $UserName -Password $Password
- $List = $Context.Web.Lists.GetByTitle($ListTitle)
- $Context.Load($List)
- $Context.ExecuteQuery()
- #Retrieve field
- $field = $List.Fields.GetByInternalNameOrTitle($FieldName)
- $Context.Load($field)
- $Context.ExecuteQuery()
- $field.SetShowInEditForm($false)
- $field.UpdateAndPushChanges($true)
- $Context.ExecuteQuery()
- write-host Done
Add Comment
Please, Sign In to add comment