VMware Cloud Community
Torrent007
Contributor
Contributor
Jump to solution

Multi-line note on VM

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
Torrent007
Contributor
Contributor
Jump to solution

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 ?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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
Jump to solution

Perfect, many thanks dude

Reply
0 Kudos