Day 30 Best Practice
Having good Security is first best practice for any language no exception with Powershell. Having that we should also we try to follow following best practices.
*Best practice is not always best. It may vary depends on our requirement. And good for one may not be good for others.
- Follow standard coding format
- Document everything
- Test everything completely before implementing on production environment.
- Maintain versioning of the code –VSS
- Use Write-Debug or Write-Verbose
- Use Write-host and write-output
- Do not run the script if you don’t know the logic/result.
- Maintain security standard try to use allsigned security policy if possible.
- Consider Day 29 – securing your data. Like SecureString, certificates, etc.
- Cleanup stuff after you have done. Means drop the object(s) once you are done with it.
- Plan first before start, then design finally implement keep the system optimize.
- Avoid Shortcuts :try to use fully qualified pathnames.
- Try to use cmdlets for most.
Below is the link by scripting guy blog where he describe the parameter alias which are not documented (only cmdlet alias are )
Great book by ScriptingGuy(Ed Wilson) “Powershell Best Practice” and webcast about Best Practice:
http://msmvps.com/blogs/richardsiddaway/archive/2011/01/11/powershell-best-practices.aspx
It was a wonderful journey of 30 days – I enjoyed each and everyday. every day was a new day and gives me something new.