Methodologies for testing code
When you are creating PowerShell Scripts, it is imperative that you test your code along the way. While there are many different development standards which you can follow such as Scrum and Agile, they all have the same premise of "test often". This section will explore recommendations for testing your code as you are developing it so that you can provide more reliable scripts.
Testing the –WhatIf argument
PowerShell offers the ability to test the cmdlet's code without actually running them. This is done by the use of the –WhatIf
argument. The –WhatIf
argument will simulate the action that the cmdlet will take on a system without actually executing the command itself. This can assist you in determining if you have the right syntax for a command. This can also benefit you if you're getting large content from a file and need to verify that the individual items in the file won't crash your script.
To use the –WhatIf
argument, perform the following action:
Get-service...