VMware Cloud Community
nanodk
Contributor
Contributor
Jump to solution

Get the value of the notes field.

Hi all,

I just started with powercli.

I want to set and get the value of the notes field.

Setting it, is done by, Set-VM -VM "VM Name" -Description "text1 text2 etc." -Confirm:$false

But how to get the value of the notes field? I though that it could be done like: Get-VM -Name "VM Name" | Get-Annotation -CustomAttribute Description

However i get an error:

Get-Annotation : 07-08-2012 11:11:28    Get-Annotation        Could not find Cu

stomAttribute with name 'Description'.
At line:1 char:44
+ Get-Vm "klj - bastionhost" | Get-Annotation <<<<  -CustomAttribute Descriptio
n
    + CategoryInfo          : ObjectNotFound: (Description:String) [Get-Annota
   tion], VimException
    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNo
   tFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetAnnotation

regard kim

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can get the VM notes field with:

Get-VM | Select-Object -Property Name,Description

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
7 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You can get the VM notes field with:

Get-VM | Select-Object -Property Name,Description

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
nanodk
Contributor
Contributor
Jump to solution

Thanks for fast reply

0 Kudos
schepp
Leadership
Leadership
Jump to solution

Robert van den Nieuwendijk wrote:

You can get the VM notes field with:

Get-VM | Select-Object -Property Name,Description

My PowerCLI says 'Description' is obsolete and you should use 'Notes' instead Smiley Wink

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is correct, see also the reference page for the VirtualMachine object.


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

You are right. I must have a blind spot in my eyes for yellow warning messages. Smiley Wink

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
Grzesiekk
Expert
Expert
Jump to solution

Hi nanodk,

  you can also check this out http://psvmware.wordpress.com/?s=annota

if you need to do more stuff with notes/description/annotations

I hope that can help as well in future Smiley Wink

"

But how to get the value of the notes field? I though that it could be  done like: Get-VM -Name "VM Name" | Get-Annotation -CustomAttribute  Description

"

It failes because description/notes is not a custom attribute, but a normal primary attribute.  In the link above you can find out more about custom attributes.

Regards,

Greg

--- @blog https://grzegorzkulikowski.info
0 Kudos
bjm534
Enthusiast
Enthusiast
Jump to solution

You should be able to do Get-VM <vmname optional> | Select-Object Name,Notes

-Brad

-Brad
0 Kudos