Sunday, 15 July 2012

When to choose development of a PowerShell Module over PowerShell Script -



When to choose development of a PowerShell Module over PowerShell Script -

i write powershell script windows administrators, in order help them in tasks related deployment of web application.

is there reason should favor or exclude development of powershell module (.psm1) instead of doing powershell script (.ps1)?

arguments develop script

simplicity: thing using script bit easier , more straightforward windows administrators not requires module installed (but might wrong not windows admin!). faster development: developing module requires more careful programming exposure of internal methods, designing api must more rigorous.

arguments develop module:

reusability: first things comes mind: if administrator wants integrate our script in own script, might easier him reuse module exposing 1 (or several) cmdlet rather invoke our script? ...

if know mutual utilize case of ps scripts vs ps modules, or technical limitations of each choice, might help.

to understand modules can you, read this: http://msdn.microsoft.com/en-us/library/dd878310(v=vs.85).aspx

in nut shell,

windows powershell modules allow partition, organize, , abstract windows powershell code self-contained, reusable units. these reusable units, administrators, script developers, , cmdlet developers can share modules straight others. script developers can repackage third-party modules create custom script-based applications. modules, similar modules in other scripting languages such perl , python, enable production-ready scripting solutions utilize reusable, redistributable components, added benefit of enabling repackage , abstract multiple components create custom solutions.

if script has functions , not written perform single task, can rename .psm1 convert module. if not using functions, of course, there no selection go .ps1. in such case, each .ps1 used perform single task. prefer modules when sharing scripts write others.

powershell module windows-scripting

No comments:

Post a Comment