Home > Hyper-V, Hyper-V R2, SCVMM, SCVMM R2, Tips&Tricks, Windows 2008 R2, Windows Server 2008 > VMM Tricks: How to get the audit trail records from a VMM Job

VMM Tricks: How to get the audit trail records from a VMM Job

Source

Today, in VMM, you can open the Administrator Console and click on the Jobs view to see all the Jobs in VMM. When you select an individual job, you can click on the “Change Tracking” tab and view any changes that were recorded in VMM as part of this job.

In this post, i will show you how to do this in PowerShell since it is not as intuitive. Basically, audit trail records that are placed in the change tracking tab are not cached on the client computer by default. the only way to surface them in powershell is to individually invoke the get-job commandlet and pass it the Job parameter while asking for the FULL job to be downloaded. the following powershell script does exactly that and displayed the audit trail records for all jobs in the system.

#get all jobs in the system
$jobs = get-job -all
foreach ($job in $jobs)
{

#get the details including the audit records for each single job in VMM
$singlejob = get-job -job $job -full
$auditrecordsexist = $singlejob | select AreAuditRecordsAvailable
if ($auditrecordsexist)
{

#if any audit records exist, print them out
foreach ($record in $singlejob.AuditRecords)
{
$record
$prev = $record.Previous
$newr = $record.New
$prev
$newr
}
}
}

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: