Creation of a command based on the available settings

Hello

It is more a question PowerShell General rather than VMware, but given that the script in question is to create a virtual machine, I'll ask here in any case.

I want to create a feature to deploy a computer virtual based on the given parameters, i.e. If for example a data store and spec of customization are given, but a model is not, of course, I don't want the - template parameter in the New - VM command as it will return a null value error.

I came up with the following which works, but I was wondering if there was a better way to do this:

    # build parameter strings
    if($template) {
        $templateParameter = " -Template $template"
    }
    if($datastore) {
        $datastoreParameter = " -Datastore $datastore"
    }
    if($custSpec) {
        $custSpecParameter = " -OSCustomizationSpec $custSpec"
    }
    if($location) {
        $locationParameter = " -Location $location"
    }


    # build deploy command string
    $deployVmCommandString = "New-VM -Name $name -VMHost $vmhost" + $templateParameter + $datastoreParameter + $custSpecParameter + $locationParameter


    # convert deploy command string to scriptblock
    $deployVmCommand = $executioncontext.invokecommand.NewScriptBlock($deployVmCommandString)


    # execute scriptblock
    Invoke-Command -ScriptBlock $deployVmCommand

Hope that you can see what I'm trying to do what above, it works, I was wondering if there is an easier way!

See you soon

Harry

Hi LucD,

Thank you for making me know the commands of Proxy, after having cleared my brain and reading through it, I like how it works!

In the end I opted for a different solution, rather than spend all the individual properties of the virtual machine to the function I spend a PSObject, pass through the properties in the object and build a chain of command based on the properties that are available, I love this solution:

    Param(
        [psobject]$vm
    )

    $deployCommandString = "New-VM"

    # build command string
    foreach ($property in $vm.psobject.properties) {
        $deployCommandString += " -" + $property.Name + " " + $property.Value
    }

        # convert deploy command string to scriptblock
    $deployCommand = $executioncontext.invokecommand.NewScriptBlock($deployCommandString)

    # execute scriptblock
    Invoke-Command -ScriptBlock $deployCommand

Thanks for your help!

Tags: VMware

Similar Questions

  • automatic creation of form elements based on the Recordset

    I would like to know how I can automatically fill in a form with text fields, radio buttons, and text boxes items.  I am attaching a video that shows what I mean.  timeline 03:45-04:25.

    It uses the CS6 version; I have CC version and cannot find a way to reproduce what the guy has done in the video in CC.

    I have a database and links already set up.  There is simply no form more Update Record Wizard. I know there is an update record server behavior that succeeded him, but the workflow is not the same thing as what is shown in the video.

    Especially when (in my case) I have to create more than 50 different forms.

    I'm guessing there are a lot of things in common to these forms. If the best solution would perhaps be to write a PHP class, or an include file, which distributes these forms where they are needed, using variables to deal with differences between the forms (and I mean not just the id of the record, but also a part of the query) this approach makes it much easier to maintain the code.

    If you write your own shapes (to do all your own codes), they will be better forms. You will learn ways to make applications more secure, user-friendly and efficient.

    I'm working on the PHP forms, daily and never wish for a tool to automate the process. If I was forced to use the DW data tools I would be more upset you're one of them be removed.

    My point is that you are naturally unhappy to have something you brought used, but I think it will be better for you in the long run. I know there are tools available third-party data. My advice is: do not replace one crutch with one another.

  • Dynamic creation of a control based on the input

    Hello

    Is it possible to change a control on the front panel?

    If the entry is a string I want to show a string. If the input is an integer, I want to show a cursor for example.

    I have a plan to implement on the different tabs and display the tab which must be shown, but maybe there's a faster, easier way?

    Thanks for the help!

    Kim

    Hi Kim,

    Thanks for the additional info.

    The dll and its manual to define what can be output and that's why you need to refer to the manual.

    When you call a dll in LabVIEW, you must set the parameters of static output and so data cannot be of a type for example if set it as a table, it will always be a table. This look for the 'node of function call' in the range of functions-> connectivity-> libraries & Executeables.

  • Cloning of the network settings on the printer - Smart zero 4.4 clients using Xen

    I ran into an issue trying to implement for thin client network printers Smart zero with the build Z6X44017 (same question for with prior build 4.3; same question for T520s, T610s, T620s): If the printer is set by the 'user' account in the HP printer Mapping utility, it does not pass by in a published desktop, XenApp as a printer available to all.  When changing the account 'user' to the 'administrator' account, the printer is listed in the printer mapping GUI.  But it is not available on the published desktop.

    However, if the printer is CREATED or MODIFIED by the administrator via the GUI HP printer Mapping on the Xen login Panel, then it is displayed as the default printer on the published desktop.

    As we seek to implement dozens of devices at once with the same network printer queue defined, it would be useful to set up once and then clone the settings.

    Here's what I've done so far:

    1 use the GUI HP printer Mapping utility to create (in administrator mode) network print queue and check that it works on the published desktop

    2. use HPDM to capture the root > printer-mapping-Bishop and root > registry values printers from that device using a task of 'files and records.

    3. apply these registry via the job template settings to the target group of devices.

    It works very well with regard to obtaining the printer to display in the GUI of the mapping of the printers on the Xen login Panel.  However, the same problem exists: unless I go again in administrator mode in the GUI and the Edit/save the printer, it is not available on the published desktop.

    A possible solution might be to run a job to 'validate' the printer settings via a program that could be run from the command line, but I can't find such a program in the file system for the Linux client.  It's just a bug in the configuration of the printer, or a limitation of this printer MUST be configured via the GUI only?

    The local HP sales engineer for thin clients was able to track down the command of "committing" the printer settings after running the registry task to copy the settings.  It is run as a task of type Script as a template file and registry.

    Here is the command to run in the script:

    /usr/share/Manticore/plugins/printer-mapping-Mgr/wrappers/apply.sh "root/printer-mapping-mgr.

    It can be added as the second subtask under the task of file & registry.

    The complete solution is:

    1 use the GUI HP printer Mapping utility to create (in administrator mode) network print queue and check that it works on the published desktop

    2. use HPDM to capture the root > printer-mapping-Bishop and root > registry values printers from that device by using a "file and registry" tasks and save it as a template

    3 edit the template to add a second sub-task of Script to run the command ' root/printer-mapping-mgr ' /usr/share/manticore/plugins/printer-mapping-mgr/wrappers/apply.sh

    4. run the task of file & registry model against the target devices.  This model will then apply these registry settings for the group target devices and run the script to validate the changes on the target devices.

  • Change the default settings for registration and opening.

    When I'm in a file and choose "Save as", I need to find the location.  But then the very next file I do the same thing and I looking for it all over again.  Is there a way to backup a specific folder or default directory at any time.  Currently, it is by default in my office in most cases.  The same thing happens when I search for a file, open it and then go to open another file in the same folder.  This seems to be a huge waste of time and was not like that in previous versions.  Thank you for any input!

    He has no control in Vista to make the changes you want to make for Vista itself.  David has provided default values for Windows 2000 and Windows XP, but not for Vista.  I can't find them for Vista- but they are what you feel and are entered into the system without installation available control to modify the default values (and I couldn't even find a way to do it with a registry hack).  Unfortunately, he must live with what you have.

    In most other cases program, it is controlled by the program itself (and varies according to the program0.  Some of these programs have commands to adjust the default settings (again, this depends on the program).  You will have to search for the documentation of the program or visit their web site (or call them for technical assistance) for more information on each program.

    I'm sorry this isn't the answer you want to hear.

    Good luck! Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • How to change the import settings when importing photos

    Changing the settings to import photo with Windows 7

    I want to change the import for my Canon camera settings when you import pictures using Windows 7.  I had already managed to do it once but to adjust settings again.  However, when I connect my camera to my PC, it starts automatically import photos based on the current settings with no option to change.  Please help - its driving me crazy!

    Microsoft seems to be lame on answering machine bugs here and just standard information messages, which of course do not work.

    A solution has been validated, in part, to david.gardiner.net.au/2010/02/changing-location-of-pictures-and.html. Maybe there is an easier way.

    In the Windows registry under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Photo Acquisition

    There are a number of subkeys. For example, there is a subkey "Camera and Portable device."

    Return the next value of AcquisitionFlags to 0 x 82 in the registry key seems to restore the Import Wizard asking you to specify an optional tag and you click again on the link "Import settings":

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Photo Acquisition\Camera and Portable device

    To make this change yourself, follow these steps (with the standard warning that change the incorrect Windows registry can completely ruin everything!):

    1. run regedit.exe
    2 navigate in the tree of the registry to find the following subkey:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Photo Acquisition\Camera and Portable device

    3. double-click on the value "AcquisitionFlags".
    4. Type "82".
    5. click "OK" and close the registry editor

    I had to scan it for my Scanner in the category.

  • Error: "this meeting uses computer audio (VoIP), computer audio is not available with this console, which is based on the Web." To get the audio from the computer, please install the Microsoft Office Live Meeting client. »

    Hello

    I have a problem with Live meeting 2007. I'm organizing a live meeting with people from different countries. Some of them cannot hear anything and can not use the microphone. They get this kind of error:

    "This meeting uses computer audio (VoIP), computer audio is not available with this console, which is based on the Web." To get the audio from the computer, please install the Microsoft Office Live Meeting client. »

    I tried to look for a solution, but I did not understand what Live Meeting I need to download.

    Can you help me?

    Thank you.

    Original title: Live Meeting 2007

    Hi Alex,

    Thanks for posting your query in Microsoft Community.

    I understand your concern. In this case, I suggest you refer to the Microsoft TechNet article following which sets out the series of frequently asked questions related to Live Meeting 2007 and check if the solutions are useful.

    FAQ: Live Meeting related topics media

    Hope this information is useful. Let us know if you need more help, we will be happy to help you.

  • How to navigate to the next page based on the value returned by the method call inside the action attribute of the command key.

    How to navigate to the next page based on the value returned by the method call inside the action attribute of the command key.

    I use JDeveloper 12.1.2.0.0

    < af:button id = "tt_b2".

    rendered = "#{attrs.nextRendered} '"

    partialSubmit = 'true '.

    action = "#{attrs.backingBean.nextAction} '"

    Text = "next".

    Disabled = "#{attrs.nextDisabled}" / >

    private static final String NEXT_NAVIGATION_ACTION = "controllerContext.currentViewPort.taskFlowContext.trainModel.getNext";

    public String nextAction() {}

    If (validate()) {}

    updateModel();

    Return NEXT_NAVIGATION_ACTION;

    }

    Returns a null value.

    }

    Use case is made for model train, which is being implemented based on this blog: http://javacollectibles.blogspot.co.UK/2014/10/ADF-train-template.html

    We define a generic action following in the model, but the action must be called under certain conditions, based on the question of whether all validation controls had been passed on no.

    You can do this in two ways:

    1 returnValue = (String) ADFUtils.invokeEL("#{controllerContext.currentViewPort.taskFlowContext.trainModel.getNext}");

    return returnValue;

    2.

    public String getNextTrainStop() {}

    String nextStopAction = null;

    ControllerContext controllerContext = ControllerContext.getInstance ();

    ViewPortContext currentViewPortCtx = controllerContext.getCurrentViewPort ();

    TaskFlowContext taskFlowCtx = currentViewPortCtx.getTaskFlowContext ();

    TaskFlowTrainModel taskFlowTrainModel = taskFlowCtx.getTaskFlowTrainModel ();

    TaskFlowTrainStopModel currentStop = taskFlowTrainModel.getCurrentStop ();

    Terminus of TaskFlowTrainStopModel = taskFlowTrainModel.getNextStop (currentStop);

    nextStopAction = nextStop.getOutcome ();

    _logger.fine ("train, next stop:"+ nextStopAction ");

    Return nextStopAction;

    }

  • What to do to get the command 'Put' to be available?

    The command 'Put' is not available.  How to do it?

    Here is how you define a site in DW. Without this step, the program is seriously hampered, and won't give you a lot of menu options: GS-01: defining a new site | Learn Dreamweaver CS5 & CS5.5 | Adobe TV

    In order to fully define the site, you will need to purchase a domain name and hosting. The company you choose will give you the necessary information for FTP to your remote server.

    To set up a local test server (if you plan to use a language such as PHP server-side), follow the steps detailed here: help Dreamweaver | Set up a test server

  • Change the command prompt based on the user login

    Hello

    I work in 11.1.1.5(11g) OBIEE. In my environment, OBIEE is integrated with OAM and user gets if authenticate in the OID Database.I a requirement where in cases that we have two users(user1,user2) and guest (prompt1, 2 guest)

    Example:
    If 1 1 user login prompt should get the display and 2 2 so quick connection of the user should get a good view.

    Can anyone help on this?

    Thank you
    Padmini

    With the help of the Administration-> catalog manage set permissions at the prompt and add the page. Based on the permissions that they might see respective guests

    If brand aid

  • disable a command button based on the values

    Hello.

    I use jdev 11.1.5

    My scenario:

    I need to disable a command button if the values of the two attributes does not match

    More inf:

    I had used a command button called Confirm.

    This button should be disabled if the debit and credit attributes did not have the same values

    You can set the disabled property of the command button to an expression something like #{! bindings.creadit.inputValue eq bindings.debit.inputValue}.

    Make sure that you set the autoSubmit property to true text entry fields and ID them as partialTriggers for the commandButton control.

    Arun-

  • create a spectrum of the order from scratch (i.e. get a fft-based on the position of the same time deductions in the sample data)

    Hello people,

    THAT THE QUESTION PERTAINS TO:

    I play on 2 parameters of a system based on the sampling time: Rotary position and vibration (accelerometer g increments).  I want to take a fft based on the post to create a spectrum of the amplitude-phase speed order in / s.  To do this, perform the following:

    1 integrate (and scale) g vibration signal in the / s (SVT Integration.vi)

    2 signal sampled vibration resample the same time at an angle similarly charged signal (ma-resample unevenly sampled input (linear interpolation) .vi)

    THE QUESTION:

    Order in which operations should be carried out, integrate then resample or vice versa?  I didn't order would be important, but using the same set of data, the results are radically different.

    OR ORDER ANALYSIS 2.0 TOOLSET:

    I have the NO order Analysis Toolset 2.0, but I could not find a way to get the speed profile generation live to work with signals of position encoder DAQmx (via pxi-6602) quadrature.  In addition, it seems that I have to specify all the commands I'm interested to watch, which I don't really know at this point (I want to see all available commands) so I decided to do my own fft based on the post to get a spectrum of the order.

    Any help is greatly appreciated.

    Chris

    The order is to integrate the time domain of first - creating a speed channel.  You now have a new channel of data.  In general I would put this in the same table of waveform with waves of acceleration time.

    Then re - sample your acceleration and/or your speed signals, and then you can calculate the spectrum of the order.

  • Routing based on the source in PIX

    Hello

    I am trying to find a way to make a routing based on the PIX source to get the same functionality of the 'road-map' command in Cisco routers; is there an equivalent command for this PIX 7.x version? I remember that it was not available in previous versions and I couldn't discover version 7.x, also, but I wanted to confirm with you double.

    Thanking in advance.

    Kind regards

    Haitham

    Haitham,

    Your interpretation is correct, Policy Based Routing is not supported on the Pix Firewall.

    Also, don't you confused when you see the command option 'road-map' Pix 6.3 and higher. This command is applicable only when redistributing routes into OSPF.

    6.3 Pix command reference:

    http://www.Cisco.com/univercd/CC/TD/doc/product/iaabu/PIX/pix_sw/v_63/cmdref/Mr.htm#wp1017196

    Command reference 7.2 pix

    http://www.Cisco.com/univercd/CC/TD/doc/product/multisec/asa_sw/v_7_2/cmd_ref/qr_711.htm#wp1648744

    Let me know if it helps.

    Kind regards

    Arul

  • How to conditionally display images based on the values of the variables

    I am building a demonstration Captivate containing a slide branching that allows the user to choose which way they want to view; Once they are done, they come back on this slide branching, and I want a check mark to display the button/path that they have already completed.

    I'm new to the use of variables and actionscript in Captivate, so I went the the documentation and the creation of variable is clear, as well as the use of conditional constructions, but I didn't know the instructions of scripts that look like they will allow me to display an image from the library when she is called in the conditional.

    Is this possible? If so, a pointer to an appropriate documentation or sample code would be greatly appreciated.

    Thank you

    Josh

    Hello

    When you insert images of the box, you click the Options tab and give the image a name that you may recognize. Then clear the Visible check box. This allows to keep hidden until you want to show it.

    However, note that even if all the image names are listed in the dialog box advanced Actions as being available for show, you will only be able to show an image if you run the fast Action of the blade where the image exists. So you will likely build a means by which you are setting up a variable to indicate that a section has been visited. Then create an action that is performed on slide enter to show the images based on the values of the variables.

    See you soon... Rick

    Useful and practical links

    Captivate wish form/Bug report form

    Certified Adobe Captivate training

    SorcerStone blog

    Captivate eBooks

  • How do I script in DIAdem to include specific lines of code (similar to .ini in LabVIEW files) based on the computer/user?

    I took Basic training courses so DIAdem Advanced and have been scripting for several months.  I am interested in how to include specific lines of code based on the computer.  Told me it would be similar to .ini in LabVIEW files, although I've never used myself .ini files.

    Hi Karen,.

    What do you mean by "includes the lines of code?  Do you mean what happens when you run a command 'ScriptInclude()' or 'ScriptCmdAdd()' in a tiara VBScript?  Or do you mean that you want to run several lines as DIAdem begins, similar to 'ScriptStart() '?

    What do you mean by "computer-based?  Do you mean you want to implement different batch files on different computers, but you are still using the same file (named) command on each target computer?  Or do you mean that you want to implement the same command on all target computers file, but you want different commands to run this file based on the computer on which you are.  In the latter case, how do you determine computer on which you are on - MAC address, logged in user name, or what?

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

Maybe you are looking for

  • Firefox crashes constantly on my htc droid incredible

    I have a HTC Droid Incredible and use firefox for some time. all of a sudden, when I try to use firefox on my phone, it opens up for a few seconds then the screen become white and then takes me to a page that says that FireFox is crashed and allows m

  • Portege R200 - W2K - unknown PCI device

    HelloI have a r200 with w2k and after installing all components, I still have an unknown PCI device... Everything works fine, I even installed these drovers that do not exist in w2k toshibas with their good will and yet... considered package previous

  • 2.1.55 blur service is temporarily unavailable

    OK last night I updated my phone and he ended up freezing on me a bit, even if subsequently. I ended up having to do a factory reset. Now, I can not connect to Motoblur to use the XT. I tried to use my regular account, in addition to creating an acco

  • Windows Media Center cannot find the tv tuner

    I have vista windows prim. My Media Center worked very well until two days have been, say, can not find tv tuner. I removed the card and to reboot, reinstall drivers. It's a 550 ATI tv tuner card. I also tried to restore.

  • How to reactivate the confirmation of RDP on disconnect

    I downloaded some Windows update last week changed my RDP disconnect confirmation so that he gave me the option "do not ask this question next time. Stupidly, I checked this box, in general, I do with all 'do not ask them again"pop-up windows, but of