How to create VMs via Powershell with specfiic requirements

So I'm looking for a way to automate VM creation and figured I would check out Powershell.
When we create VMs, we have a template folder that has sysprep'd files for the C, D, and P drives that we use.  Some of our hosts are 2012 and some are 2012 R2.  With R2 we create Gen2 machines which use different types of HDD setups inside of
Hyper-V so not sure if there are different commands for that.
When I create a VM by hand, I create the VM normally and choose to attach a HDD later.  I then go get the Template for C and copy it into the folder that gets created automatically by Hyper V.  I then create matching folders in the area that we
store the D and P drives and copy those template files in as well.  I then go back into Hyper-v, modify the settings of the VM and attach/browse to the files to add in the 3 drives.  I also then have to enable VLans and put in the proper VLan number.
Once those things are done, I fire up the VM and use it normally.
So I know I can use the new-vm command to create the VM, but I'm assuming I'd have to create the needed folders and copy over the needed files prior to doing that.  Can I specify all the above information in the new-vw command or do I need to create
the VM and the modify the VM once it's there?
I've not used Powershell to do much with VMs, and definitely not to create them, so I'm just looking to get pointed down the right path before I start one way and then have to start over.
Thanks!!

This sounds like a great project to learn more about some base, PowerShell cmdlets, and the Hyper-V module's cmdlets. I'm pretty certain you can get this accomplished using the following cmdlets:
New-VM: To create the VM.
Get-VM: To get information about your new VM, such as it's location (path), where you will do your copying. Try Get-VM -Name
nameofyourvm | Select-Object * and you'll see some paths.
Copy-Item: Copy your C template from its source, to the destination you get from Get-VM cmdlet above.
New-Item: To create a folder for D and P drives, again using the path from Get-VM.
Copy-Item: Copy your D and P templates.
From here out you may need Set-VM to "modify the settings" of the VM, a drive cmdlet or two to attach the drives, and a network cmdlet or two to get your VLANs setup. To see all the Hyper-V cmdlets, enter Get-Command -Module Hyper-V. Everything
you'll likely need is in there. When you see one you want to read more about, use the Get-Help cmdlet. You can also narrow down the cmdlets returned by Get-Command by doing things like this: Get-Command -Module Hyper-V -Noun '*drive*' -and- Get-Command -Module
Hyper-V -Noun '*network*'.
Start with the first step - creating a new VM with the New-VM cmdlet. It includes the parameter -NoVHD that will allow you to create the VM without attaching a virtual drive. There are a few other parameters you'll likely want to include when you create your
VM. One is -Generation where you indicate 1 or 2. Study the New-VM cmdlet from it's help file (Get-Help New-VM -ShowWindow) and get this part complete. When you're done, you can move on to creating folders, copying files, connecting drives, etc.

Similar Messages

  • How to create material via Idoc with empty material field

    Hello.
    I have to take over materials from a 46c system to an ECC5 system and I want to use Idocs.
    Some of the materials must keep their old numbers, some must change with a new number which have to be define automatically following the internal range number rules of the customizing.
    I thought we just had to make the matnr field empty in the E1MARAM segment and so, SAP would assign automatically the new number, but it doesn't work.
    I also tried to put '/' (nodata) character in the field, but I just reached to create an material with '/' number. :-(((((((.
    Does anyone know a solution ?
    Thank you in advance for all your advices.
    David

    Hello James and happy new year.
    Thank you for your answer.
    In fact, I already tried to leave the matnr field with blanks and for a material type which use internal numbers range. I hoped/thought it would have worked as you said but it wouldn't.
    About the external old numbers I keep, I think I don't have to use the field external_number of the E1MARA1 segment, because some of my tests showed me that it works good. Moreover, I don't really understand the reason why this field exists because the field matnr is here for.
    I presume that the external_number is maybe for another use I don't know, aren't you ?
    I've never used this segment for data take over.
    Do you know if the principle you described in your previous mail is also the same to apply to customers & vendors idocs ?
    Best regards.
    David

  • How to create a csv file with NCS attributes?

    Hi
    i installed Cisco Prime NCS and trying to perform bulk update of device credentials with csv file.
    How to create a csv file with all required attributes?
    This is part of NCS online help talking about this topic:
    Bulk Update Devices—To update the device credentials in a bulk, select Bulk Update Devices from the Select a command drop-down list. The Bulk Update Devices page appears.You can choose a CSV file.
    Note        The CSV file contains a list of devices to be updated, one device per line. Each line is a comma separated list of device attributes. The first line describes the attributes included. The IP address attribute is mandatory.
    Bellow is test csv file i created but does not work:
    10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    The error i am getting while importing this file:
    Missing mandatory field [ip_address] on header line:10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    Assistance appreciated.

    It looks like the IP address field is incorrectly set.,
    It should be as follows
    {Device IP},{Device Subnet Mask}, etc etc
    so a practical example of the aboove could be (i dont know if this is completely correct after the IP address / Subnet Mask)
    10.64.160.31,255.255.255.0,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    below is a link to the documentation
    http://www.cisco.com/en/US/docs/wireless/ncs/1.0/configuration/guide/ctrlcfg.html#wp1840245
    HTH
    Darren

  • Create MP via Powershell in SCOM 2012 SP1

    Is it possible to create MP via Powershell in SCOM 2012 SP1? If so, how?
    (New-SCOMManagementPack is unrecognized cmdlet) 

    $name="NewMP"
    $displayname="NewMP"
    $mpStore = New-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore
    $mp = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPack($name, $displayName, (New-Object Version(1, 0, 0,0)), $mpStore)
    import-scommanagementpack $mp

  • How to create an unsolved cube with awm???

    hi all,
    I readed the "Oracle Olap developer's guide to the Oalp api" and I found there's 2 type of Cube: Solved and Unsolved Cubes. And this document says: "... if all the data for a cube is specified by the DBA, then the cube is considered to be Solved. If some or all of the aggregate data must be calculated by Oracle OLap, then the cube is unsolved ..."
    I tried with awm 10.2.0.3.0A to create an unsolvedCube but I can't. All cubes I created are solvedCube. To know if a cube is solved or unsolved, I wrotte an program in Java to read informations of package mtm.
    Some one can tell me how to create an unsolved cube with AWM ou other soft please!

    SH is not a relational OLAP data model which is quite different from the GLOBAL schema which is based on an Analytic Workspace.
    If you change the aggregation method you will need to re-compute the whole cube which can be a very big job! You might be able to force the unsolved status be de-selecting all the levels on the Rules tab in AWM. However, I think by default analytic workspace OLAP models always provide a fully solved cube to the outside world. This is the nature of the multi-dimensional model.
    Relationally, as keys are located in separate columns a cube can be unsolved in that the key column only contains values for a single level from the corresponding dimension tables. If more than keys for different levels within the same dimension appear within the fact key column then the cube is deemed as being solved.
    Therefore, I am not sure you are going to get the information you require from the API. To changes the aggregation method you will have to switch off all pre-compute options and also disable the session cache to prevent previously calculated data being returned when you change the aggregation method.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

  • How to create a Sales order with ref to Contract using Function Module

    How to create a Sales order with ref to Contract using Function Module BAPI_SALESDOCU_CREATEFROMDATA ?

    We have a unique situation where we like change the sold-to customer of the sales order
    once order has been created. These orders have been created using either by function module
    BAPI_SALESDOCUMENT_COPY or using BDC (VA01, Copy with reference).
    These two processes work abosolutely fine except someone might have change the sold-to
    customer of the ship-to customer of the original sales order. If this the case then the new
    sales order will be created with the old sold-to and with not the new sold-to.
    We tried using BAPI_SALESDOCUMENT_CHANGE and commit afterwards. We checked
    the returned parameteres of the BAPIs and they are all successful but sold-to remains the
    same old one.
    Any help would be much more appreciated.

  • How to create a pdf file with CS5

    Hello, I'm new to PhotoShop CS5 and haven't figured out yet (despite two hours of trying) how to create a pdf file with pictures and texts.  Can someone please help me with this ?  The "help" button in CS5 doesn't seem to cover this question.  Nor do the FAQs.
    Thank you very much.

    Save As... Photoshop PDF.

  • How to create  a test plan with specific transactions (or program)

    Hello,
    I'm a new user in Sol Man !
    How to create  a test plan with specific transactions (or program).
    In my Business Blueprint (SOLAR01) I've created in 'transaction tab' the name of my specific transactions and linked it.
    In my test plan (STWB_2) those specific doesn't appear to be selected !
    Thanks in advance.
    Georges HUYNEN

    Hi 
    In solar01 you have defined but you have to assign the test case in solar02 for this test case in the test cases tab.
    When you do so expand the business sceanario node in test plan generation of STWB_2 transaction and now that will appear.
    Also visit my weblog
    /people/community.user/blog/2006/12/07/organize-and-perform-testing-using-solution-manager
    please reward points.

  • How to create a web template with company logo

    how to create a web template with company logo . can any one help me with the steps. or any notes. thnaks in advance .
    2. i have 25000 articles and client want to have a selection feild to see top article ex:50,10,20, 100, 1000 etc . same for bottom articles . plz let me know how to do it . thanks for replay . i am new bw so plz .
    thanks to you all

    Hi
    1) Please read
    http://help.sap.com/saphelp_nw04/helpdata/en/4a/c8353c51aab32be10000000a114084/frameset.htm
    2) Create a condition in the Query Designer: Use a formula variable
    See http://help.sap.com/saphelp_nw04/helpdata/en/73/702e39074dc93de10000000a114084/frameset.htm
    Heike

  • How to create a transport request with query and only with its structure.

    HI guru,
                how to create a transport request with query and only with its structure.transport request should not  include any other query items like ( variables, conditions...etc)
    thanks in advance.
    venkata

    Hi,
    Goto RSA1 and then Transport Connection -> In SAP Transports select Object Types-> Query Elements -> Then select Query->Give Technical name of the query and then select for transfer. In the right side you can choose the components which you wanted to transport.
    Regards,
    anil

  • How to create a procedure function with a return value of ref cursor?

    Can anybody provide a sample about how to create a procedure function with a return value of REF CURSOR?
    I heard if I can create a function to return a ref cursor, I can use VB to read its recordset.
    Thanks a lot.

    http://osi.oracle.com/~tkyte/ResultSets/index.html

  • How to create an install cd with the final cut pro x app if the app comes from App.Store?

    How to create an install cd with the final cut pro x app if the app comes from App.Store?

    Just copy the Application FCPX to your CD. When you want to install drag the FCPX to the Application folder and you are done.

  • How to create item wise invoice with reference to sales order.

    Hi ,
    Please let me know how to create item wise invoice with reference to sales order.
    Ex : Sales order has 2 line items .
              When creating invoice system should create two invoices for each line items.
    I have tried with copy control but I am not able to do it.
    Please advise.
    Regards

    Hi,
    Please let us know your exact requirement. Whether you want it to be fixed like only one line item to be billed every time ot it to be based on selection you do every time.
    As per my understanding it should not be fixed and in that case it should like as follows,
    In VF01 you will select Del. document/S.O. number and click on selection list and will take you to next screen as mention below,
    and select desire line item to be billed and click on copy and will take you to billing screen.
    Regards,
    Ajit K Singh

  • How to create Web Service Proxy with help of WSDL.

    Hi ,
    How to create Web Service Proxy with help of WSDL .
    Please help me .
    Thanks in advacne for reply .

    check out this article. It has all the details
    http://www.oracle.com/technology/products/jdev/howtos/1013/wsadf/adfcomplexwstypes.html

Maybe you are looking for

  • Alv report with grid example

    i want some example alv grid report example

  • Programming in other languages?

    Are programming languages available in any other language aside from English or are terms such as public/private/double/abstract etc etc used in every country?

  • Comformation of Core Duo-based MacBook/Macbook Pro Upgrade 'N' path

    In an attempt to shorten these threads concerning MacBook/Macbook Pro Upgrade 'N' path using Apple's (AirPort Extreme Upgrade Kit **NEW** Model BCM94321MC) Part #'s MA688Z/B or MA688Z/A (The only difference between the two part numbers appears to be

  • Need Help Ending File

    Write a program to read a list of nonnegative integers and to display the largest integer, the smallest integer, and the average of all the integers. The user indicates the end of the input by entering a negative sentinel value that is not used in fi

  • Spool printing using multiple printer trays.

    Hello, Has anyone printed the same SAP spool using multiple printer trays? For example, the spool has 3 pages, the first page use tray 1, page 2 and 3 use tray 2. How this can be accomplished? Your input is appreciated. Regards, Sue