?
Solved

P2V scripting in Windows PowerShell..

Posted on 2008-10-30
4
Medium Priority
?
2,112 Views
Last Modified: 2012-08-13
P2V scripting

I have a P2V script which is attached that is working but when I try to start the VM using VMware Server Console the server just blue screens each time.

I am also posting the XML config file that I am using.

What I am trying to accomplish is to have my server P2Ved each night deleting the old P2V files as a backup.. also have the script send me an email telling me the start time and end time of the job. I am running this script in windows power shell.

The script works and finishs at 100% and I get the email just as I want. I end up with 2 files 1) servername.vmdk and 2) servername.vmx

And help? Is there a list of switches I can use with the P2VTool.exe? am I using the wrong switches? Im thinking the switch I am using is P2Ving the server for an ESX server and I need to P2V it for VMware Server Console not ESX.

THIS IS THE SCRIPT
 
    #Get the start time for the email message.
 
$startTime = get-date
 
&C:\Program Files (x86)\VMware\VMware Converter\P2VTool.exe --import --source 
C:\job\nsbb.xml
 
    #Get the finish time for the email message.
 
$finishTime = get-date
 
Move-Item C:\ConverterTemp\NSBB\* C:\Converter\NSBB force
 
Remove-Item C:\ConverterTemp\NSBB
 
    #Set up the email parameters and send the email.
 
 
$emailFrom = "Tad@******.com"
$emailTo = "Tad@******.com"
$subject = "VM Migration Task Complete..."
$body = "Your VM Migration started at: $startTime
 
Your VM Migration completed at: $finishTime
 
Please log into the Virtual Infrastructure Client to remove
any unnecessary hardware and ensure that the newly migrated
VM is on the correct network."
$smtpServer = "********"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
 
________________________________________________________________________
THIS IS THE XML CONFIG
 
<p2v uninstallAgentOnSuccess="0" version="2.2" xmlns="http://www.vmware.com/v2/sysimage/p2v" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/v2/sysimage/p2v p2vJob.xsd" xsi:type="P2VJob">
  <source>
    <liveSpec>
      <creds host="10.2.1.8" password="*****" port="0" username="NS\administrator"/>
    </liveSpec>
  </source>
  <dest>
    <hostedSpec path="\\10.2.1.6\ConverterTemp" password="******" username="NS\administrator" vmName="NSBB"/>
  </dest>
  <importParams clonePagefile="true" diskType="MONOLITHIC_SPARSE" keepIdentity="false" preallocateDisks="false" preserveDeviceBackingInfo="false" targetProductVersion="PRODUCT_WS_5X">
    <nicMappings preserveNicsInfo="false">
      <nicMapping network="Bridged"/>
    </nicMappings>
    <volumesToClone>
      <volumeCloneInfo newSize="12962482790" resize="true" volumeId="attVol={computer={8d56326b536472341b75b4f61b479869dbeb1967},1}"/>
    </volumesToClone>
  </importParams>
  <postProcessingParams installTools="false" powerOnVM="false">
    <reconfigParams/>
  </postProcessingParams>
  <jobState errorCode="0" id="8" startTime="2008-Oct-30 14:39:35" state="beingStopped" totalPercentComplete="18" type="import">
    <messages>
      <message id="Id_EstablishConnectionToAgent" type="Type_NewStep">
        <parameters>
          <parameter value="10.2.1.8"/>
        </parameters>
      </message>
      <message id="Id_CreateAndImport" type="Type_NewStep"/>
      <message id="Id_CreateConfigInfo" type="Type_Info"/>
      <message id="Id_CreateTargetVM" type="Type_Info"/>
      <message id="Id_FormatVolumeWithPath" type="Type_Info">
        <parameters>
          <parameter value="c:"/>
        </parameters>
      </message>
      <message id="Id_SnapshottingVolume" type="Type_Info"/>
      <message id="Id_CloningVolumeWithPath" type="Type_Info">
        <parameters>
          <parameter value="c:"/>
        </parameters>
      </message>
    </messages>
  </jobState>
</p2v>

Open in new window

0
Comment
Question by:ctrunk514
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:BSonPosh
ID: 22842791
Perhaps I am confused, but you should always have two files... one is disk file and one is config file.
0
 

Author Comment

by:ctrunk514
ID: 22843203
OK yes i have 2 file after the script runs, when i use the VMware Converter i can start the server and everthing works. but when i use the script the servre trys to start but blue screen..
0
 
LVL 18

Expert Comment

by:BSonPosh
ID: 22876070
I thought I would have time to poke around and figure this out, but alas I have not. I recommend you going to http://communities.vmware.com/community/developer/windows_toolkit and post your question there.
0
 

Accepted Solution

by:
ctrunk514 earned 0 total points
ID: 22881764
I found the answer!!!!
In my script i was missing "--postprocess" switch.. after using this the script runs and i can start my VM's

here is the script I am using I hope this helps other people trying to automate the P2V process and wants an email alert when the job is finished

Keep in mind this script needs to be run in Windows powershell 1.0, I use windows task scheduler with a bat file that calls this script.. each night I get e new P2V deleting the old one..

__________________________________________________________________________________

    #Get the start time for the email message.

$startTime = get-date

    #Run the p2vtool.exe utility to convert the VM from one ESX box to another.

&C:\Program Files (x86)\VMware\VMware Converter\P2VTool.exe --postprocess --import --source C:\job\nsbb.xml

    #Get the finish time for the email message.

$finishTime = get-date

Move-Item C:\ConverterTemp\NSBB\* C:\Converter\NSBB force

Remove-Item C:\ConverterTemp\NSBB

    #Set up the email parameters and send the email.


$emailFrom = "VM-P2V@********.com"
$emailTo = "Tad@********.com"
$subject = "VM Migration Task Complete for NSBB..."
$body = "Your VM Migration started at: $startTime

Your VM Migration completed at: $finishTime

Please log into the Virtual Infrastructure Client to ensure that the newly migrated
VM is on the correct network."
$smtpServer = "nsmail.ns.local"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
0

Featured Post

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Teach the user how to install log collectors and how to configure ESXi 5.5 for remote logging Open console session and mount vCenter Server installer: Install vSphere Core Dump Collector: Install vSphere Syslog Collector: Open vSphere Client: Config…
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question