VMware Cloud Community
devid79
Enthusiast
Enthusiast
Jump to solution

List of al VMs with all fields

Hello guys,

i need help to extract from my VCenter, with powercli script , all information like this :

Name

State

Uptime

NIC

PortGroup

  1. S.O.

IP

Host

Provisioned Space

Used Space

CPU

RAM

Reservation - RAM/CPU

VMDK / Datastore

Host CPU - MHz

Host Mem - MB

Notes

Fault Tolerance

Snapshot

VMWare Tools

NB_LAST_BACKUP

Tags

and send email on cvs and html format.

Please help me.

Thx

Davide

Tags (3)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Some more properties.

But there are a few that are already there (VMWare Tools) and some that are not too clear to me.

In fact this a massive request, some of these are worth a separate thread in their own right.

$report = @()

foreach($vm in Get-View -ViewType Virtualmachine){

    $vms = "" | Select-Object VMName, Hostname, IPAddress, OS, Boottime, VMState, TotalCPU, CPUAffinity,

         CPUHotAdd, CPUShare, CPUlimit, OverallCpuUsage, CPUreservation, TotalMemory, MemoryShare, MemoryUsage,

         MemoryHotAdd, MemoryLimit, MemoryReservation, Swapped, Ballooned, Compressed, TotalNics, ToolsStatus,

          ToolsVersion, HardwareVersion, TimeSync, CBT, Portgroup, VMHost, ProvisionedSpaceGB, UsedSpaceGB, Datastore,

          Notes, FaultTolerance

    $vms.VMName = $vm.Name

    $vms.Hostname = $vm.guest.hostname

    $vms.IPAddress = $vm.guest.ipAddress

    $vms.OS = $vm.Config.GuestFullName

    $vms.Boottime = $vm.Runtime.BootTime

    $vms.VMState = $vm.summary.runtime.powerState

    $vms.TotalCPU = $vm.summary.config.numcpu

    $vms.CPUAffinity = $vm.Config.CpuAffinity

    $vms.CPUHotAdd = $vm.Config.CpuHotAddEnabled

    $vms.CPUShare = $vm.Config.CpuAllocation.Shares.Level

    $vms.TotalMemory = $vm.summary.config.memorysizemb

    $vms.MemoryHotAdd = $vm.Config.MemoryHotAddEnabled

    $vms.MemoryShare = $vm.Config.MemoryAllocation.Shares.Level

    $vms.TotalNics = $vm.summary.config.numEthernetCards

    $vms.OverallCpuUsage = $vm.summary.quickStats.OverallCpuUsage

    $vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage

    $vms.ToolsStatus = $vm.guest.toolsstatus

    $vms.ToolsVersion = $vm.config.tools.toolsversion

    $vms.TimeSync = $vm.Config.Tools.SyncTimeWithHost

    $vms.HardwareVersion = $vm.config.Version

    $vms.MemoryLimit = $vm.resourceconfig.memoryallocation.limit

    $vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

    $vms.CPUreservation = $vm.resourceconfig.cpuallocation.reservation

    $vms.CPUlimit = $vm.resourceconfig.cpuallocation.limit

    $vms.CBT = $vm.Config.ChangeTrackingEnabled

    $vms.Swapped = $vm.Summary.QuickStats.SwappedMemory

    $vms.Ballooned = $vm.Summary.QuickStats.BalloonedMemory

    $vms.Compressed = $vm.Summary.QuickStats.CompressedMemory

    $vms.Portgroup = Get-View -Id $vm.Network -Property Name | select -ExpandProperty Name

    $vms.VMHost = Get-View -Id $vm.Runtime.Host -property Name | select -ExpandProperty Name

    $vms.ProvisionedSpace = [math]::Round($vm.Summary.Storage.UnCommitted/1GB,2)

    $vms.UsedSpace = [math]::Round($vm.Summary.Storage.Committed/1GB,2)

    $vms.Datastore = $vm.Config.DatastoreUrl[0].Name

    $vms.Notes = $vm.Config.Annotation

    $vms.FaultTolerance = $vm.Runtime.FaultToleranceState

    $Report += $vms

}

Send-MailMessage -Subject 'VM List' -To 'me@domain.com' -from 'you@domain.com' `

     -SmtpServer mail.domain.com `

    -BodyAsHtml -Body ($report | ConvertTo-Html | Out-String)


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

View solution in original post

58 Replies
LucD
Leadership
Leadership
Jump to solution

What do you have already in your script?

Which properties are missing?


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

Reply
0 Kudos
devid79
Enthusiast
Enthusiast
Jump to solution

thx for reply

this is the script, but i need to export all info from vcenter , with attribute "Tags", "snapshoot" etc. i need if possible with this info

Name

State

Uptime

NIC

PortGroup

  1. S.O.

IP

Host

Provisioned Space

Used Space

CPU

RAM

Reservation - RAM/CPU

VMDK / Datastore

Host CPU - MHz

Host Mem - MB

Notes

Fault Tolerance

Snapshot

VMWare Tools

NB_LAST_BACKUP

All Tags

$vm = Get-View $_.ID

$vms = "" | Select-Object VMName, Hostname, IPAddress, OS, Boottime, VMState, TotalCPU, CPUAffinity, CPUHotAdd, CPUShare, CPUlimit, OverallCpuUsage, CPUreservation, TotalMemory, MemoryShare, MemoryUsage, MemoryHotAdd, MemoryLimit, MemoryReservation, Swapped, Ballooned, Compressed, TotalNics, ToolsStatus, ToolsVersion, HardwareVersion, TimeSync, CBT,

$vms.VMName = $vm.Name

$vms.Hostname = $vm.guest.hostname

$vms.IPAddress = $vm.guest.ipAddress

$vms.OS = $vm.Config.GuestFullName

$vms.Boottime = $vm.Runtime.BootTime

$vms.VMState = $vm.summary.runtime.powerState

$vms.TotalCPU = $vm.summary.config.numcpu

$vms.CPUAffinity = $vm.Config.CpuAffinity

$vms.CPUHotAdd = $vm.Config.CpuHotAddEnabled

$vms.CPUShare = $vm.Config.CpuAllocation.Shares.Level

$vms.TotalMemory = $vm.summary.config.memorysizemb

$vms.MemoryHotAdd = $vm.Config.MemoryHotAddEnabled

$vms.MemoryShare = $vm.Config.MemoryAllocation.Shares.Level

$vms.TotalNics = $vm.summary.config.numEthernetCards

$vms.OverallCpuUsage = $vm.summary.quickStats.OverallCpuUsage

$vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage

$vms.ToolsStatus = $vm.guest.toolsstatus

$vms.ToolsVersion = $vm.config.tools.toolsversion

$vms.TimeSync = $vm.Config.Tools.SyncTimeWithHost

$vms.HardwareVersion = $vm.config.Version

$vms.MemoryLimit = $vm.resourceconfig.memoryallocation.limit

$vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

$vms.CPUreservation = $vm.resourceconfig.cpuallocation.reservation

$vms.CPUlimit = $vm.resourceconfig.cpuallocation.limit

$vms.CBT = $vm.Config.ChangeTrackingEnabled

$vms.Swapped = $vm.Summary.QuickStats.SwappedMemory

$vms.Ballooned = $vm.Summary.QuickStats.BalloonedMemory

$vms.Compressed = $vm.Summary.QuickStats.CompressedMemory

$Report += $vms

}

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, let's tackle this step by step.

The following will send an email with a HTML body.

Starting from that what is still missing?

$report = @()

foreach($vm in Get-View -ViewType Virtualmachine){

    $vms = "" | Select-Object VMName, Hostname, IPAddress, OS, Boottime, VMState, TotalCPU, CPUAffinity,

         CPUHotAdd, CPUShare, CPUlimit, OverallCpuUsage, CPUreservation, TotalMemory, MemoryShare, MemoryUsage,

         MemoryHotAdd, MemoryLimit, MemoryReservation, Swapped, Ballooned, Compressed, TotalNics, ToolsStatus,

          ToolsVersion, HardwareVersion, TimeSync, CBT

    $vms.VMName = $vm.Name

    $vms.Hostname = $vm.guest.hostname

    $vms.IPAddress = $vm.guest.ipAddress

    $vms.OS = $vm.Config.GuestFullName

    $vms.Boottime = $vm.Runtime.BootTime

    $vms.VMState = $vm.summary.runtime.powerState

    $vms.TotalCPU = $vm.summary.config.numcpu

    $vms.CPUAffinity = $vm.Config.CpuAffinity

    $vms.CPUHotAdd = $vm.Config.CpuHotAddEnabled

    $vms.CPUShare = $vm.Config.CpuAllocation.Shares.Level

    $vms.TotalMemory = $vm.summary.config.memorysizemb

    $vms.MemoryHotAdd = $vm.Config.MemoryHotAddEnabled

    $vms.MemoryShare = $vm.Config.MemoryAllocation.Shares.Level

    $vms.TotalNics = $vm.summary.config.numEthernetCards

    $vms.OverallCpuUsage = $vm.summary.quickStats.OverallCpuUsage

    $vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage

    $vms.ToolsStatus = $vm.guest.toolsstatus

    $vms.ToolsVersion = $vm.config.tools.toolsversion

    $vms.TimeSync = $vm.Config.Tools.SyncTimeWithHost

    $vms.HardwareVersion = $vm.config.Version

    $vms.MemoryLimit = $vm.resourceconfig.memoryallocation.limit

    $vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

    $vms.CPUreservation = $vm.resourceconfig.cpuallocation.reservation

    $vms.CPUlimit = $vm.resourceconfig.cpuallocation.limit

    $vms.CBT = $vm.Config.ChangeTrackingEnabled

    $vms.Swapped = $vm.Summary.QuickStats.SwappedMemory

    $vms.Ballooned = $vm.Summary.QuickStats.BalloonedMemory

    $vms.Compressed = $vm.Summary.QuickStats.CompressedMemory

    $Report += $vms

}

Send-MailMessage -Subject 'VM List' -To 'me@domain.com' -from 'you@domain.com' -SmtpServer mail.domain.com `

    -BodyAsHtml -Body ($report | ConvertTo-Html | Out-String)


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

devid79
Enthusiast
Enthusiast
Jump to solution

ok , i appreciade

portgroup DVS, host, provisioned space, used space, host, datastore/vmdk, cpu/mhz, host/mem,mb, fault tollrance, snapshoot, vmtools, NB_last_backup, tags, notes.

thank you

i appreciating your help

i wait here

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Some more properties.

But there are a few that are already there (VMWare Tools) and some that are not too clear to me.

In fact this a massive request, some of these are worth a separate thread in their own right.

$report = @()

foreach($vm in Get-View -ViewType Virtualmachine){

    $vms = "" | Select-Object VMName, Hostname, IPAddress, OS, Boottime, VMState, TotalCPU, CPUAffinity,

         CPUHotAdd, CPUShare, CPUlimit, OverallCpuUsage, CPUreservation, TotalMemory, MemoryShare, MemoryUsage,

         MemoryHotAdd, MemoryLimit, MemoryReservation, Swapped, Ballooned, Compressed, TotalNics, ToolsStatus,

          ToolsVersion, HardwareVersion, TimeSync, CBT, Portgroup, VMHost, ProvisionedSpaceGB, UsedSpaceGB, Datastore,

          Notes, FaultTolerance

    $vms.VMName = $vm.Name

    $vms.Hostname = $vm.guest.hostname

    $vms.IPAddress = $vm.guest.ipAddress

    $vms.OS = $vm.Config.GuestFullName

    $vms.Boottime = $vm.Runtime.BootTime

    $vms.VMState = $vm.summary.runtime.powerState

    $vms.TotalCPU = $vm.summary.config.numcpu

    $vms.CPUAffinity = $vm.Config.CpuAffinity

    $vms.CPUHotAdd = $vm.Config.CpuHotAddEnabled

    $vms.CPUShare = $vm.Config.CpuAllocation.Shares.Level

    $vms.TotalMemory = $vm.summary.config.memorysizemb

    $vms.MemoryHotAdd = $vm.Config.MemoryHotAddEnabled

    $vms.MemoryShare = $vm.Config.MemoryAllocation.Shares.Level

    $vms.TotalNics = $vm.summary.config.numEthernetCards

    $vms.OverallCpuUsage = $vm.summary.quickStats.OverallCpuUsage

    $vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage

    $vms.ToolsStatus = $vm.guest.toolsstatus

    $vms.ToolsVersion = $vm.config.tools.toolsversion

    $vms.TimeSync = $vm.Config.Tools.SyncTimeWithHost

    $vms.HardwareVersion = $vm.config.Version

    $vms.MemoryLimit = $vm.resourceconfig.memoryallocation.limit

    $vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

    $vms.CPUreservation = $vm.resourceconfig.cpuallocation.reservation

    $vms.CPUlimit = $vm.resourceconfig.cpuallocation.limit

    $vms.CBT = $vm.Config.ChangeTrackingEnabled

    $vms.Swapped = $vm.Summary.QuickStats.SwappedMemory

    $vms.Ballooned = $vm.Summary.QuickStats.BalloonedMemory

    $vms.Compressed = $vm.Summary.QuickStats.CompressedMemory

    $vms.Portgroup = Get-View -Id $vm.Network -Property Name | select -ExpandProperty Name

    $vms.VMHost = Get-View -Id $vm.Runtime.Host -property Name | select -ExpandProperty Name

    $vms.ProvisionedSpace = [math]::Round($vm.Summary.Storage.UnCommitted/1GB,2)

    $vms.UsedSpace = [math]::Round($vm.Summary.Storage.Committed/1GB,2)

    $vms.Datastore = $vm.Config.DatastoreUrl[0].Name

    $vms.Notes = $vm.Config.Annotation

    $vms.FaultTolerance = $vm.Runtime.FaultToleranceState

    $Report += $vms

}

Send-MailMessage -Subject 'VM List' -To 'me@domain.com' -from 'you@domain.com' `

     -SmtpServer mail.domain.com `

    -BodyAsHtml -Body ($report | ConvertTo-Html | Out-String)


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

devid79
Enthusiast
Enthusiast
Jump to solution

Dear,

Yes, this is a massive request for a monthly report,

thx for reply I think you just miss snapshoots, tags and NB_last_backup

see attachments.

many thx

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

What exactly do you want to see for Snapshots, just the name(s)?

Or just an indication that the VM has snapshots?


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

Reply
0 Kudos
devid79
Enthusiast
Enthusiast
Jump to solution

yes but if possible to see  the date creation and size, and fields Tag for owner

Thx so much bro for you help i wait you

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

How shall the script package all that info in one property?

Join everything together in one string?


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

Reply
0 Kudos
devid79
Enthusiast
Enthusiast
Jump to solution

Hello, thx for reply,

is this information possible?, extracted and inserted as we did for the others?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Some properties added

$report = @()

foreach($vm in Get-View -ViewType Virtualmachine){

    $vms = "" | Select-Object VMName, Hostname, IPAddress, OS, Boottime, VMState, TotalCPU, CPUAffinity,

         CPUHotAdd, CPUShare, CPUlimit, OverallCpuUsage, CPUreservation, TotalMemory, MemoryShare, MemoryUsage,

         MemoryHotAdd, MemoryLimit, MemoryReservation, Swapped, Ballooned, Compressed, TotalNics, ToolsStatus,

          ToolsVersion, HardwareVersion, TimeSync, CBT, Portgroup, VMHost, ProvisionedSpaceGB, UsedSpaceGB, Datastore,

          Notes, FaultTolerance, SnapshotName, SnapshotDate, SnapshotSizeGB, Tags, NB_last_backup

          

    $vms.VMName = $vm.Name

    $vms.Hostname = $vm.guest.hostname

    $vms.IPAddress = $vm.guest.ipAddress

    $vms.OS = $vm.Config.GuestFullName

    $vms.Boottime = $vm.Runtime.BootTime

    $vms.VMState = $vm.summary.runtime.powerState

    $vms.TotalCPU = $vm.summary.config.numcpu

    $vms.CPUAffinity = $vm.Config.CpuAffinity

    $vms.CPUHotAdd = $vm.Config.CpuHotAddEnabled

    $vms.CPUShare = $vm.Config.CpuAllocation.Shares.Level

    $vms.TotalMemory = $vm.summary.config.memorysizemb

    $vms.MemoryHotAdd = $vm.Config.MemoryHotAddEnabled

    $vms.MemoryShare = $vm.Config.MemoryAllocation.Shares.Level

    $vms.TotalNics = $vm.summary.config.numEthernetCards

    $vms.OverallCpuUsage = $vm.summary.quickStats.OverallCpuUsage

    $vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage

    $vms.ToolsStatus = $vm.guest.toolsstatus

    $vms.ToolsVersion = $vm.config.tools.toolsversion

    $vms.TimeSync = $vm.Config.Tools.SyncTimeWithHost

    $vms.HardwareVersion = $vm.config.Version

    $vms.MemoryLimit = $vm.resourceconfig.memoryallocation.limit

    $vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

    $vms.CPUreservation = $vm.resourceconfig.cpuallocation.reservation

    $vms.CPUlimit = $vm.resourceconfig.cpuallocation.limit

    $vms.CBT = $vm.Config.ChangeTrackingEnabled

    $vms.Swapped = $vm.Summary.QuickStats.SwappedMemory

    $vms.Ballooned = $vm.Summary.QuickStats.BalloonedMemory

    $vms.Compressed = $vm.Summary.QuickStats.CompressedMemory

    $vms.Portgroup = Get-View -Id $vm.Network -Property Name | select -ExpandProperty Name

    $vms.VMHost = Get-View -Id $vm.Runtime.Host -property Name | select -ExpandProperty Name

    $vms.ProvisionedSpaceGB = [math]::Round($vm.Summary.Storage.UnCommitted/1GB,2)

    $vms.UsedSpaceGB = [math]::Round($vm.Summary.Storage.Committed/1GB,2)

    $vms.Datastore = $vm.Config.DatastoreUrl[0].Name

    $vms.Notes = $vm.Config.Annotation

    $vms.FaultTolerance = $vm.Runtime.FaultToleranceState

    $vms.SnapshotName = &{$script:snaps = Get-Snapshot -VM $vm.Name; $script:snaps.Name -join ','}

    $vms.SnapshotDate = $script:snaps.Created -join ','

    $vms.SnapshotSizeGB = $script:snaps.SizeGB -join ','

    $vms.Tags = (Get-TagAssignment -Entity $vm.Name).Tag.Name -join ','

    $vms.NB_last_backup =  Get-VM -Name $vm.Name | select -ExpandProperty Customfields | where{$_.Key -eq 'Last Backup'} | select -ExpandProperty Value

    $Report += $vms

}

Send-MailMessage -Subject 'VM List' -To 'me@domain.com' -from 'you@domain.com' `

     -SmtpServer mail.domain.com `

    -BodyAsHtml -Body ($report | ConvertTo-Html | Out-String)


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

devid79
Enthusiast
Enthusiast
Jump to solution

Wow, bro ,  i start the script, and i have this error:

Gathering VM statistics

cmdlet ForEach-Object at command pipeline position 3

Supply values for the following parameters:

Process[0]:

then i received the doc,  but in the fields Total Memory and provisioned space zero data received Smiley Sad

many thx bro

pastedImage_1.pngpastedImage_2.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure where this coming fro, the script doesn't contain a message "Gathering VM statistics".

Did you add lines to the script?

If yes, can you attach your version?


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

Reply
0 Kudos
devid79
Enthusiast
Enthusiast
Jump to solution

#Gathering VM settings

Write-Host "Gathering VM statistics"

$Report = @()

Get-VM | Sort Name -Descending | %

$report = @()

foreach($vm in Get-View -ViewType Virtualmachine){

    $vms = "" | Select-Object VMName, Hostname, IPAddress, OS, Boottime, VMState, TotalCPU, CPUreservation, TotalMemoryGB, MemoryUsage, MemoryReservation, TotalNics, ToolsStatus, ToolsVersion, HardwareVersion, TimeSync, CBT, Portgroup, VMHost, ProvisionedSpaceGB, UsedSpaceGB, Datastore, Notes, FaultTolerance

    $vms.VMName = $vm.Name

    $vms.VMState = $vm.summary.runtime.powerState

    $vms.Boottime = $vm.Runtime.BootTime

    $vms.TotalNics = $vm.summary.config.numEthernetCards

    $vms.Portgroup = Get-View -Id $vm.Network -Property Name | select -ExpandProperty Name

    $vms.OS = $vm.Config.GuestFullName

    $vms.Hostname = $vm.guest.hostname

    $vms.IPAddress = $vm.guest.ipAddress

    $vms.VMHost = Get-View -Id $vm.Runtime.Host -property Name | select -ExpandProperty Name

    $vms.ProvisionedSpaceGB = [math]::Round($vm.Summary.Storage.UnCommitted/1GB,2)

    $vms.UsedSpaceGB = [math]::Round($vm.Summary.Storage.Committed/1GB,2)

    $vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

    $vms.CPUreservation = $vm.resourceconfig.cpuallocation.reservation       

    $vms.TotalCPU = $vm.summary.config.numcpu

    $vms.TotalMemoryGB = $vm.summary.config.memorysizem

    $vms.MemoryUsage = $vm.summary.quickStats.guestMemoryUsage   

    $vms.ToolsStatus = $vm.guest.toolsstatus

    $vms.ToolsVersion = $vm.config.tools.toolsversion

    $vms.TimeSync = $vm.Config.Tools.SyncTimeWithHost

    $vms.HardwareVersion = $vm.config.Version

    $vms.MemoryReservation = $vm.resourceconfig.memoryallocation.reservation

    $vms.Datastore = $vm.Config.DatastoreUrl[0].Name

    $vms.CBT = $vm.Config.ChangeTrackingEnabled 

    $vms.Datastore = $vm.Config.DatastoreUrl[0].Name

    $vms.Notes = $vm.Config.Annotation

    $vms.FaultTolerance = $vm.Runtime.FaultToleranceState

    $vms.SnapshotName = &{$script:snaps = Get-Snapshot -VM $vm.Name; $script:snaps.Name -join ','}

    $vms.SnapshotDate = $script:snaps.Created -join ','

    $vms.SnapshotSizeGB = $script:snaps.SizeGB -join ','

    $vms.Tags = (Get-TagAssignment -Entity $vm.Name).Tag.Name -join ','

    $vms.NB_last_backup =  Get-VM -Name $vm.Name | select -ExpandProperty Customfields | where{$_.Key -eq 'Last Backup'} | select -ExpandProperty Value

    $Report += $vms

}

#Output

if ($GridView -eq "yes") {

$report | Out-GridView }

if ($CreateCSV -eq "yes") {

$report | Export-Csv $FileCSV -NoTypeInformation }

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

These lines are casing that, remove them

$Report = @()

Get-VM | Sort Name -Descending | %

Are the VMs for which you get the 0 values powered on?


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

devid79
Enthusiast
Enthusiast
Jump to solution

thx bro, yes correct,i remove the lines but the script, but the script after add some entries, appear not run or in idle.

I think the fields are:

$vms.Tags = (Get-TagAssignment -Entity $vm.Name).Tag.Name -join ','  "the custom tag used is Owner" change vm.name to Owner in field?

$vms.NB_LAST_BACKUP =  Get-VM -Name $vm.Name | select -ExpandProperty Customfields | where{$_.Key -eq 'NB_LAST_BACKUP'} | select -ExpandProperty Value

when commented the lines the script function

#$vms.SnapshotName = &{$script:snaps = Get-Snapshot -VM $vm.Name; $script:snaps.Name -join ','}
#$vms.SnapshotDate = $script:snaps.Created -join ','
#$vms.SnapshotSizeGB = $script:snaps.SizeGB -join ','
#$vms.Tags = (Get-TagAssignment -Entity $vm.Name).Tag.Name -join ','
#$vms.NB_LAST_BACKUP =  Get-VM -Name $vm.Name | select -ExpandProperty Customfields | where{$_.Key -eq 'NB_LAST_BACKUP'} | select -ExpandProperty Value
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

How do you mean "not run"?

Are there any messages?

You want to check if a specific tag named Owner is present?

Or is that TagCategory?

Can you perhaps show a screenshot of such a Tag?


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

Reply
0 Kudos
devid79
Enthusiast
Enthusiast
Jump to solution

yes thx bro

You want to check if a specific tag named Owner is present?  "is Category Name"

Can you perhaps show a screenshot of such a Tag? "Is Tag Name"

pastedImage_3.png

pastedImage_0.png

But when i start the script with all enable fields, i have no result and message,  i have the result but snap fileds is clear no result Smiley Sad

When i start with this last filed

#$vms.SnapshotName = &{$script:snaps = Get-Snapshot -VM $vm.Name; $script:snaps.Name -join ','}
$vms.SnapshotDate = $script:snaps.Created -join ','
$vms.SnapshotSizeGB = $script:snaps.SizeGB -join ','
#$vms.Tags = (Get-TagAssignment -Entity $vm.Name).Tag.Name -join ','
#$vms.NB_LAST_BACKUP =  Get-VM -Name $vm.Name | select -ExpandProperty Customfields | where{$_.Key -eq 'NB_LAST_BACKUP'} | select -ExpandProperty Value
$Report += $vms

pastedImage_4.png

i wait you bro

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Do you still have the line $report = @() before the ForEach loop?

You have to declare the array


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

Reply
0 Kudos