![]() I have created a new parameter “ filename” that accepts the name of the text file and here is an example of call with that parameter: Get-LastBootUpTime -filename "OKFINservers.txt" -errorlog -client "OK" -solution "FIN" -Verbose | Out-GridView Then we do not need to worry about how many servers we want to check since we can just add new servers in the text file and continue calling the same CmdLet without making it cumbersome and without changing anything in syntax when calling CmdLet. Wouldn’t it be nice to have another parameter in the same CmdLet that will accept the name of the text file and that text file to contain the list of servers? I hope you get the picture as I add more and more server names to the “ computers” parameter than the call to Get-LastBootUpTime CmdLet gets longer and longer which is not very neat in my opinion and code becomes cluttered very fast. Result of Get-LastBootUpTime CmdLet for two computers ![]() Get-LastBootUpTime is part of the Efficiency Booster PowerShell Project which is the library of many awesome CmdLets so please check it out. IMPORTANT: The source code for this CmdLet is here. I wanted to get information when a bunch of servers was last time restarted so I have written my own CmdLet Get-LastBootUpTime with parameter “ computers” that accept a list of string arrays representing server names. Let me quickly illustrate with a few examples. to get different results from the same PowerShell CmdLet or Advanced Function dependent on input parameters provided.to have the flexibility of getting the same result of PowerShell CmdLet or Advanced Function with different input parameters depending on the situation and when some parameter(s) are more appropriate than other(s),.Read More Why Do We Want To Create PowerShell Parameter Setsīefore we dive in the steps how to create PowerShell Parameter Sets lets discuss some of the reasons why we want to have PowerShell Parameter Sets in the first place:.Useful PowerShell Parameter Set Articles. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |