VMware Cloud Community
prasanna22kumar
Contributor
Contributor

Required an VMotion History Script.

 

Required power shell script to pull out the Motion history , Attached the screenshot for the same...Required the output in the same manner.

 

Kindly help me on the same.

 

Thanks,

Kumar.

Reply
0 Kudos
19 Replies
LucD
Leadership
Leadership

You could start from my Events – Part 8 – VMotion History post.


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Thanks for your reply..!!

I tried that script, But the output is not the same. 

The output comes as attached screen shot "Motion-Capture", But kindly help me out to get the Output as below

NameTypeSrcHostDstHostSrcDatastoreDstDatastoreSrcDCDstDCDurationStartTimeEndTimeUsernameChainIDServer

 

Thanks in advance.

Cheers,

Kumar.

 

Reply
0 Kudos
LucD
Leadership
Leadership

The script will provide you with all the events that were created due to a vMotion.
You can extract additional properties from those events.

I don't assume you want me to write your script for you?


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

LucD,

Kindly write the script for me...Please.

Thanks,

Kumar.

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

Any luck on it ..??

 

Reply
0 Kudos
LucD
Leadership
Leadership

Perhaps you didn't see it as such, but my question was meant to be sarcastic 

I don't assume you want me to write your script for you?


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

Sorry, I never thought it as sarcastic, Since I was new to power cli , So I requested to assist me on the script to make changes as the required output.

 

Thanks,

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

Since I'm new to Scripting , Whe I tried running this Cmdlet ..it throws the attached error,kindly assist me how to execute it.

 

Get-VIEventPlus

Get-MotionHistory.

Using the following 

PowerCLI12.1.0 Version

Powershell 5.1 Version.

Any other modules as to installed...Kindly suggest me ..Please

 

Thanks,

Kumar

Reply
0 Kudos
LucD
Leadership
Leadership

You have to copy the two functions in a .ps1 file.
And then call the function, as I showed in my blog post.

To create a .ps1 file, place some content in there and run the script, have a look at for example How to create and run a PowerShell script file on Windows 10
It shows you all the steps you need to take to run a PowerShell script.


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

Good day

When I'm trying to run this cmdlet "Get-MotionHistory -Entity (Get-VM VM*) -Days 1"  ,I'm getting an attached error.

When I copied 2 function's nothing was happening, So when I tried with above Command, It was through an error.

Kindly help me out. 

Regards,

Kumar.

Reply
0 Kudos
LucD
Leadership
Leadership

That is the same error you posted earlier.
You seem to be calling the function from the PS prompt.

You have to place both functions, together with your call of the function, in a .ps1 file.
And call that .ps1 file.

Or dot-source a .ps1 file containing both functions, before calling the function from the PS prompt.

This is basic PS.
Did you actually read the post I pointed to on how to run PS code?


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

Thanks for you Advice & Guidance.

When I run the script, Below is the output of it.

VMTime1Host1DRS1
xcpnhrhr300226-11-2020 09:20xfpnhidsx029FALSE

 

But few fields are missing in it ,Below is the format for the same,  Kindly can help me on it ...Please.

NameTypeSrcHostDstHostSrcDSDstDSSrcDCDstDCDurationStartTimeEndTimeUsernameChainIDServer
xcpfhbmas001vMotionxfpfhidsx035xfpfhidsx038FH_P_L_CLUESXCSP002P_DTS_015FH_P_L_CLUESXCSP002P_DTS_015VDC-ServiceProviderVDC-ServiceProvider00:00:4920-07-2020 23:1220-07-2020 23:13DRS52056668wcpnhidvc

Regards,

Kumar.

Reply
0 Kudos
LucD
Leadership
Leadership

Great, you got it working.

Now have a look at my Get The VMotion/SvMotion History post.
That expands on the previous post I linked to.
You'll notice that not all the information you want to see is available for all events.


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd, 

So you want me to combine both scripts & Run it or Kindly advice me how to proceed ..Please  assist me.

Thanks in advance.

Regards,

Kumar

Reply
0 Kudos
LucD
Leadership
Leadership

No, those are new functions, they are built on the same concept as the previous one.


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

I copied "Get the vMotion/svMotion history" in a different PS1, Tried executing it …But I didn't get any output. Kindly advice me if anything as to be modified on the script.

Below is the few lines I added on the top of the Script (i.e. .Get the vMotion/svMotion history)

$hours = 24 # Number of hours back
$start = (Get-Date).AddHours(-$hours)
$tasknumber = 999 # Windowsize for task collector
$eventnumber = 100 # Windowsize for event collector
$tgtTaskDescriptions = "VirtualMachine.migrate","Drm.ExecuteVMotionLRO"
$migrations = @()
$report = @()
# Get the guest for which we want the report
$vmHash = @{}
Get-Datacenter -Name "VDC-ServiceProvider" | Get-VM | %{
$vmHash[$_.Name] = $_.Host
}

Thanks in advance

Regards,

Kumar

Reply
0 Kudos
LucD
Leadership
Leadership

And where are you calling the function?
There is a sample call in that blog post.


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

I'm trying to call in the beginning of the script, If it's wrong..!! Kindly help where exactly it should be called...Please ..Since this script is very urgent & important.

If don't mind ..Kindly write it for me this time....Please.

It's an request ….!!

Regards,

Kumar.

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

It's working, But I required "ChainID" also, How can I include the same into the script...Please

Below is the OUTPUT,

"CreatedTime","Type","UserName","VM","SrcVMHost","TgtVMHost","SrcDatastore","TgtDatastore"

Regards,

Kumar.

Reply
0 Kudos