powershellansibleansible-awxansible-toweransible-module

Parsing vars from Ansble to powershell


I have created my own module. This module executes a powershellscript.

But now I need to overgive them some variables, how can I do this.

I already have tried with this:

$data = Get-Content $args[0] | Out-String | ConvertFrom-Json

But that doesnt work.

Do you have any suggestions?


Solution

  • Piping to Out-String is not necessary here. You can utilize the -Raw switch on Get-Content if you want to read file contents as a single string:

    $data = Get-Content $args[0] -Raw | ConvertFrom-Json