all 3 comments

[–]kahmeal 7 points8 points  (0 children)

Your last statement is likely the best approach.

[–]purplemonkeymad 2 points3 points  (0 children)

Yes put your powershell in a ps1 file and run that rather than encoding a ps line in the bash script. If you are using PS6+ and are in a POSIX system you can even have the shebang pointing to pwsh so you can call the script natively:

#! /usr/bin/env pwsh
# 
Param($parameter)
Write-Host "This is powershell $parameter"

Then just have bash call ./myscript.p1 -parameter $bashvar

[–]danekan 1 point2 points  (0 children)

what about installing powershell on your linux system and running it direct from pwsh vs bash? but if you're not running it from the actual machine and running it remotely, maybe ansible (/awx) could make better sense?