VMware Cloud Community
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Find VM Guest with Logging Disabled and Enable

Hi All,

Just finished a support call with VMware and unfortunately the vmware.log wasn't updated due the logging being disabled.

I found random VMs with this issues, there was probably a template with this parameter which got deployed several times.

.

I need a way to scan all guests for this parameter and cheange the value to true, any help would be appreciated

Nicholas
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

And with this line you can scan what the setting is on your VMs

Get-VM | Select Name, @{N="Logging Enabled";E={$_.ExtensionData.Config.Flags.enableLogging}}


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

View solution in original post

Reply
0 Kudos
7 Replies
kunaludapi
Expert
Expert
Jump to solution

Virtual Machine logging | LucD notesLucD notes

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
LucD
Leadership
Leadership
Jump to solution

And with this line you can scan what the setting is on your VMs

Get-VM | Select Name, @{N="Logging Enabled";E={$_.ExtensionData.Config.Flags.enableLogging}}


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

Reply
0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

Hi Luc,

Thanks, can help filter out enableLogging -eq TRUE then I can output that to CSV using Export-csv, then if its not too much trouble set guest VM eq FALSE to TRUE ?

Nicholas
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can use my function from Virtual Machine logging to enable logging.

Something like this

Get-VM | 
Where {!$_.ExtensionData.Config.Flags.enableLogging} | %{
 
Set-VMLogging -VM $_ -Logging:$true
}

To report on the VM that have logging enabled, you can do something like this

Get-VM | 
Where {$_.ExtensionData.Config.Flags.enableLogging} |
Select Name, @{N="Logging Enabled";E={$_.ExtensionData.Config.Flags.enableLogging}} |
Export-Csv report.csv -NoTypeInformation -UseCulture


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

nicholas1982
Hot Shot
Hot Shot
Jump to solution

Hi Luc,

That's great, is there anyway to report on guest with logging disabled rather than enabled ?

Nicholas
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, change this line

Where {$_.ExtensionData.Config.Flags.enableLogging} |


to

Where {!$_.ExtensionData.Config.Flags.enableLogging} |


The ! negates the Boolean that follows.


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

Reply
0 Kudos
Mahiee
Enthusiast
Enthusiast
Jump to solution

I tried by keeping "!" still report is filled up with logging enabled VMs, without "!" and with both reports VMs are same. can you please suggest on it

Reply
0 Kudos