I am creating Site Columns on SharePoint Online via PowerShell scripts by taking field xml data from an xml file, unable to figure out how to show progress of Site Columns creation as there are around 100+ fields and console is static for a very long time. Below is the PowerShell script code.
.....
.....
$web = $site.RootWeb
$fields = $web.Fields
$clientContext.Load($web)
$clientContext.Load($fields)
$clientContext.ExecuteQuery()
<#Import field xml from SiteColumnsData.xml file#>
Write-Host "Getting fields from XML file" -ForegroundColor Magenta
[xml]$s = Get-Content -Path ".\SiteColumnsDataTest.xml"
$fieldslist = $s.SelectNodes("/SiteColumns/Fields/Field")
$fieldslist | Foreach-Object {
$fieldName = $fieldslist.Name
Write-Host "Current Field is" $fieldName
$field = $_.OuterXml.ToString()
$fields.AddFieldAsXml($field, $true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView) | Out-Null
$clientContext.Load($fields)
}
Write-Host "Creating Columns....WAIT..." -ForegroundColor Yellow
$clientContext.ExecuteQuery()
....
.....
$clientContext.ExecuteQuery()
. So you know when the server created the fields.