Now with the below command when I am trying to highlight the value (Freespace in %) column if its below 10%, its not working. Looks like the if condition is not working in hash table, as only else condition is getting applied even if the space is below 10%.
Ah ok … I see … There’s no easy or builtin way to achieve what you’re trying to do. You cannot mix automatically by PowerShell formatted output with parts of it with Write-Host. Something like this has been asked a thousand times already and it does not work as you might think it does.
You would need to parse the output and reformat each single line again with Write-Host. Most of the times it’s just not worth it.
Of course you can still filter the output for the disks with less than 10% and limit the output to these particular disks. Or you could sort it for the “FreeSpace in %” and make it more obvious this way. Or you could add another property only showing if the free space is less than 10%. There are a lot of ways to “highlight” certain properties without using color.