Enthusiast
Enthusiast

Invoke-VMScript and many Bash commands

Jump to solution

Hi!

I have multiple bash commands.

In real time i type command, then enter, then enother command and enter again. etc

How i can use all command in 1 $script?

This dos'nt work:

$script = "

/sbin/pvresize

/sbin/lvresize

"

Invoke-VMScript -VM MyVM -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword P@ssw0rd

Thanks!

0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

Try with a here-string

$script = @'

/sbin/pvresize

/sbin/lvresize

'@

Invoke-VMScript -VM MyVM -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword P@ssw0rd


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
Leadership
Leadership

Try with a here-string

$script = @'

/sbin/pvresize

/sbin/lvresize

'@

Invoke-VMScript -VM MyVM -ScriptType bash -ScriptText $script -GuestUser root -GuestPassword P@ssw0rd


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
Enthusiast
Enthusiast

Many thanks!

0 Kudos
Enthusiast
Enthusiast
Any variables defined inside $script, are not working. Any workaround?
0 Kudos
Leadership
Leadership

They are, but it depends how you defined the script as inline text (with or without variable substitution), and if you escaped the dollar signs in the variables if you selected variable substitution.
Can you share you code, so I can have a look?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos