You can use Get-ItemField
function to get all item fields and loop through them as below to read them.
$item = Get-Item -Path "master:" -ID "{{Item_ID}}"
$fields = $item | Get-ItemField -ReturnType Field
foreach($field in $fields){
Write-Host "Field Name: $($field.Name)"
Write-Host "Field Value: $($item.Fields[$field.Name].Value)"
}
This will return all the fields on the item which are not standard fields. In case you would like to fetch standard fields as well you can add -IncludeStandardFields
flag to Get-ItemField
function.
Note: In ordercase you need to make sureuse $item.Fields
returnsto return all the fields, you will need to call $item.Fields.ReadAll()
function before reading item fields as below.
$item.Fields.ReadAll()
# exclude standard fields.
$fields = $item.Fields | Where-Object { $_.Name -notlike '__**' }
We need to call ReadAll()
function as above since Fields are lazy loaded, hence the call to this function is required to read all the fields.
Hope this helps!!!