Howto write PowerShell Cmdlet in C# using Visual Studio 2012: Write Verbose Output

So we’ve come to the part when it’s time to learn how to write verbose output just like the feature “Write-Verbose” in normal PowerShell functions.

Once again I continue my work on my first DLL. You can read part 1, 2, 3 and 4 on the blog.

PoSh-Class-Step5-001

Here we use “WriteObject” to write a string as standard output to the command line. Then we write the line “A verbose output.”, but only if we run the function with the “–Verbose”-parameter like this

Get-DifferentOutputs –Verbose

After that, but only if we use the “–Debug”-parameter we write “A debug output.” and the we write a warning to the screen. Like this

PoSh-Class-Step5-002

 

/Tim

About The Author

Tim Nilimaa is a consultant with Lumagate in Sweden. He has been working with Configuration Manager for 8 years. His knowledge has been selected as a speaker at many events among them Microsoft Management Summit.

No Comments