Concept: A list of codes and showing how to improve that.


Don’t do that #1: Multiple lines to initialize variables

Don’t do that #2: Multiple lines to read variables

Don’t do that #3: Multiple Write-Host to add new lines

Don’t do that #4: Don’t ask the user to write in upper case

Don’t do that #5: Specify the type of variable with Read-Host

Don’t do that #6: Use Clear-Host to prevent the output

Don’t do that #7: Multiple lines to create variables with the same prefix

Don’t do that #8: Get all properties instead of specific one

Don’t do that #9: Use Write-Host for verbose messages

Don’t do that #10: Use Exception.Message to catch an error in Catch block

Don’t do that #11: Reload a module with Remove-Module and Import-Module

Don’t do that #12: Use several lines to get the parent container path of an AD user object

Don’t do that #13: Use Write-Host to properly align the output

Don’t do that #14: Use Add method to multiple elements when creating an hashtable

Don’t do that #15: Use Add method to multiple elements when creating an array

Don’t do that #16: Use the For loop to create an infinite loop

Don’t do that #17: Silent the errors with $ErrorActionPreference = ‘SilentlyContinue’

Don’t do that #18: Use a loop For to get the line number

Don’t do that #19: Use double quotes to escape characters

Don’t do that #20: Use too many parameters in one line (use splatting instead)

Don’t do that #21: Use multiple Replace to select numbers in a string

Don’t do that #22: Manage a remote server using RDP

Don’t do that #23: Use Where-Object to search a user with filter (like)

Don’t do that #24: Use Get-QADUser to receive AllMemberOf of a user

Don’t do that #25: Manually add whitespaces for padding strings

Don’t do that #26: Test the network status of a computer within the process block

Don’t do that #27: Use Foreach-Object instead of of ByPropertyName

Don’t do that #28: Increment the number of examples in Comment-Based Help

Leave a Reply

Your email address will not be published. Required fields are marked *