Hi @NGaur-3476
This is due to Write-Host and Write-Output being two completely different commands. The Write-Output command does not have the -ForegroundColor flag, so you will not be able to use it for this.
However, you can install TMOutput as described in https://tommymaynard.com/write-output-gets-foreground-and-background-colors-and-more-2016/
Install-Module -Name TMOutput
TMOutput 1.1
https://www.powershellgallery.com/packages/TMOutput/1.1
Write-Host
Write-Output
------------------------------------
If this is helpful please accept answer.