VMware Cloud Community
MehdiF
Enthusiast
Enthusiast
Jump to solution

part of the information contained in a column "Notes"

Hi,

I would like extract part of the information contained in a column "Notes"  my script is 

Get-Cluster -Name "XXX" | Get-VM | Select-Object Name ,Notes

Name        Cluster       Notes 

VM1           Cluster1    Application 1 backup date

 

I would like to list 

Name        Cluster     Notes 

VM1           Cluster1    Application 1

For this i try to use regex but the result don't match

(Get-VM).Notes[0][0]

Anyone can help me ? 

Thank you very much for your replys 

 

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Then you could do something like this

Get-VM |
Select Name,@{N='Note';E={$_.Notes.Split("`n")[0]}}


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

How is that info entered in the Notes field?
Is that a multi-line entry?
And do you only want to extract the 1st line?


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

Reply
0 Kudos
MehdiF
Enthusiast
Enthusiast
Jump to solution

Hello Luc, 

 

Yes there are multi-line entry. and i would like extrat the first line. 

the colomun is like below 

Name Apply

Last Backup

Last run time

etc...

 

Thank you 🙂 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Then you could do something like this

Get-VM |
Select Name,@{N='Note';E={$_.Notes.Split("`n")[0]}}


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

Reply
0 Kudos
MehdiF
Enthusiast
Enthusiast
Jump to solution

Yes it's done

Thank you again 🙂 

 

 

Reply
0 Kudos