This blog post is actually t share one of my utility script. We all write scripts to automate our tasks. We often(or always) write scripts which will be consumed by an end user as well. In this case logging is an inevitable part for a script.
We all(at least me) start developing a script initially without any logs and once the skeleton is ready we will start putting enough logs to it and one of the most important part of logging in a script is the user inputs log, We should be logging the values provided by the end user(except secrets), which will help anyone to troubleshoot if the script fails.
I always had situations to put or enhance logs for existing scripts. As a person who loves automation, I thought of automating the maximum possible for this, which actually ended up in this small utility script.
The below script will allow us to get the expression that we can put in our Script and covers the user inputs, basically the parameters and its values.
More details in Get-Help .\Build-ParamLog.ps1 -Full
The script is available in TechNet script center as well. Link
Hopes this saves copy pastes and mouse clicks...
Enjoy exploring PowerShell !!!
We all(at least me) start developing a script initially without any logs and once the skeleton is ready we will start putting enough logs to it and one of the most important part of logging in a script is the user inputs log, We should be logging the values provided by the end user(except secrets), which will help anyone to troubleshoot if the script fails.
I always had situations to put or enhance logs for existing scripts. As a person who loves automation, I thought of automating the maximum possible for this, which actually ended up in this small utility script.
The below script will allow us to get the expression that we can put in our Script and covers the user inputs, basically the parameters and its values.
More details in Get-Help .\Build-ParamLog.ps1 -Full
The script is available in TechNet script center as well. Link
Hopes this saves copy pastes and mouse clicks...
Enjoy exploring PowerShell !!!
No comments:
Post a Comment