Is there a workaround to stop Update-FormatData complaining about a loaded file when the format file is already loaded in the session
I will answer my question here: as I can’t post an answer to my question for 8 hours.
I did enough Google but could’t find anything before posting the question then I thought there must be a Get- for the format data!!!
I think this should do it
$T = Get-FormatData | Where-object {$_.TypeName -eq "ffps.data"}
if ( $T -eq $null ){
Write-Debug "Load $formatfile"
Update-FormatData -PrependPath $formatfile
}
I guess you mean this error:
Update-FormatData : There were errors in loading the format data file:
Microsoft.PowerShell, C:\test.Format.ps1xml : File skipped because it was already present from “Microsoft.PowerShell”.
To suppress the error use the ErrorAction parameter:
UPDATE
There is a cmdlet to get the format data (v2), Get-FormatData: