Partager via


Using the Write-Warning Cmdlet

Writing a Warning Message to the Console Window

The Write-Warning cmdlet is designed to write a warning message to the screen. What’s cool about Write-Warning is that this message appears, by default, in bright yellow, making it clearly stand out in the console window:

Write-Warning is also one of the simplest of all cmdlets; all you do is call Write-Warning followed by the warning message you want to display:

Write-Warning "The folder C:\Scripts2 does not exist."

That’s all there is to it.