Torrent007
Contributor
Contributor

Multi-line note on VM

Jump to solution

Hi all,

Anyone knows how, in PowerCLI, set a multiline note on a VM ?

Target goal is to do something like that in VM note:

2020-01-14 - Torrent - Doing something awesome

2019-12-31 - Noobs - Doing blabla

I don't know which chars or which way I have to use to create this new line

Thanks Smiley Happy

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Try like this.
In PS the backtick-n represents a new-line

Get-VM -Name MyVM |

Set-VM -notes "Line 1`nLine 2" -Confirm:$false


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership

Try like this.
In PS the backtick-n represents a new-line

Get-VM -Name MyVM |

Set-VM -notes "Line 1`nLine 2" -Confirm:$false


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

View solution in original post

0 Kudos
Torrent007
Contributor
Contributor

I tried before posting and that's not worked, with simple quote...

With double, that's good Smiley Happy

By the way, I need to read this new line fron Read-Host command, and that's not working Smiley Sad :

pastedImage_2.png

Have you any idea how can I force interpretation of input string ?

0 Kudos
LucD
Leadership
Leadership

Yes, when you populate the variable with Read-Host, the string you enter (with the backtick-n) is not expanded.

You will have to force that expansion.

$answer = Read-Host -Prompt "New notes"

Get-VM -Name MyVM |

Set-VM -Notes $ExecutionContext.InvokeCommand.ExpandString($answer) -Confirm:$false


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

Torrent007
Contributor
Contributor

Perfect, many thanks dude

0 Kudos