Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
459 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...