[PowerShell]
###########################################
Add-Type -Path “C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll”
Add-Type -Path “C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll”
###########################################
$siteURl = Read-Host “Enter the site URL”
$username= Read-Host “Enter the username”
$password=read-host “Enter password” -AsSecureString
$listName= read-host “Enter List Name”
$columnName=Read-Host “Enter the list column name”
$option=Read-Host “Do you want to hide the column ” $columnName “(Y/N) “
###########################################

$context= New-Object Microsoft.SharePoint.Client.ClientContext($siteURl)
$credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$password)
$context.Credentials=$credentials

$webs=$context.Web.Webs
$context.Load($webs)
$context.ExecuteQuery()
#############################################

$fields=$context.Web.Fields
$context.Load($fields)
$context.ExecuteQuery()

#Write-Host $fields.Count

$list=$context.Web.Lists.GetByTitle($listName)
$context.Load($list)
$context.ExecuteQuery()

$listfields=$list.Fields

$context.Load($listfields)
$context.ExecuteQuery()

Write-Host “List column count” $listfields.Count
foreach($listfield in $listfields)
{

#Write-Host $listfield.Title “;” $listfield.Id

if($listfield.Title -eq $columnName)
{

if($option.ToLower() -eq “y” -or $option.ToLower() -eq “yes”)
{
$listfield.Hidden=$true
Write-Host “Column ” $columnName “‘s hidden property has been changed to ‘Yes’ “
}

if($option.ToLower() -eq “n” -or $option.ToLower() -eq “no”)
{
$listfield.Hidden=$false
Write-Host “Column ” $columnName “‘s hidden property has been changed to ‘No’ “
}

$listfield.Update()
$context.Load($list)
$context.ExecuteQuery()

}

}

[/PowerShell]