Add shared functions to module_utils/powershell.ps1 and refactor powershell modules to utilize the common powershell code

This commit is contained in:
Matt Martz 2014-06-17 18:20:33 -05:00
commit a25c441300
11 changed files with 66 additions and 137 deletions

View file

@ -27,4 +27,23 @@
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Helper function to parse Ansible JSON arguments from a file passed as
# the single argument to the module
Function Parse-Args($arguments)
{
$parameters = New-Object psobject;
If ($arguments.Length -gt 0)
{
$parameters = Get-Content $arguments[0] | ConvertFrom-Json;
}
$parameters;
}
# Helper function to set an "attribute" on a psobject instance in powershell.
# This is a convenience to make adding Members to the object easier and
# slightly more pythonic
Function Set-Attr($obj, $name, $value)
{
$obj | Add-Member -Force -MemberType NoteProperty -Name $name -Value $value
}