Using Powercli I have difficulty to modify the hardware vm and nic portgroup during deployment of the model

Hello

I was wondering if anyone can help, I am deploying 1 or more vm several templates, variables are imported from a csv file, each line is a new virtual machine with the specific name, ip, gateway, host, data store, etc..  The provisions of the virtual machine without problem, but I can't seem to change the amount of cpu, memory, nic portgroup, nic IP 1 or 2.  Any help in this would also be great, if there was a way to get the VM starts after the procurement process which would be even better.

Import-Csv deploy.csv -UseCulture | %{

    function UpdateVMSettings {
    Write-Host "Changing Portgroup and virtual Hardware..."
    Set-VM $"Server Name" | Get-OSCustomizationSpec $_.Customization | -MemoryMB $_.MemoryMB -NumCpu $_.NumCpu -Confirm:$false
    Set-VM $"Server Name" | Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '1'} | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" -SubnetMask 255.255.255.0 -DefaultGateway $_."GW" -Confirm:$false
    Set-VM $"Server Name" | Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '2'} | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."Maint IP Address" -SubnetMask 255.255.0.0 -DefaultGateway $_."GW" -Confirm:$false
    Get-VM |Get-NetworkAdapter |Where {$_.NetworkName -eq 140 } |Set-NetworkAdapter -NetworkName $VLAN -Confirm:$false
    }
  
    $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" `
    -Datastore $_.Datastore -OSCustomizationSpec $_.Customization `
    -Confirm:$false -RunAsync
}

I'm sure you can tell I'm not a programmer by any means, I play a little in powercli, look on the forums and try to adapt to what I see to my needs, sometimes it works, sometimes it doesn't but I'll try , thanks in advance for any advice, anyone could have.

I must have completely forgotten this, but why are there at - it a function declaration in line 2?

You call this function anywhere?

Memory and the setting of the CPU on line 14 will first have to a Get-VM . Somethine like that

Get-vm-name $_. "" Server name "| Set-VM - MemoryGB $_. MemoryGB - NumCpu $_. NumCpu

Tags: VMware

Similar Questions

  • I have a 4th generation iPad and the display is damaged. I bought in the States, but I'm not living there more. I live in the Brazil. What should I do to have difficulty here in the Brazil?

    I have a 4th generation iPad and the display is damaged. I bought in the United States, but I'm not living there more. I live in the Brazil. What should I do to have difficulty here in the Brazil?

    damage to the screen is not covered by the warranty - see if this offer your answer > https://www.apple.com/support/ipad/repair/screen-damage/

  • Word 2007 your AutoCorrect, MSO1033.acl, file could not be saved. The file may be read-only, or you do not have permission to modify the file.

    To get this message when opening Word 2007.

    Your AutoCorrect file, (Japanese weird character? with) MSO1033.acl, could not be saved. The file may be read-only, or you do not have permission to modify the file.

    ALSO when I try to close or save a Word 2007 I get this message:

    Word cannot save or create this file. Make sure that the disk you want to save the file on is not full, write-protected, or damaged. (C:\Program Files\... Normal.dotm)

    I then click on Cancel to not save the changes and then get the following message appears:

    Changes have been made that affect the model overall, Normal. You want to save these changes?

    I click No. in addition to this I'm currently not able to print from word 2007 older that I created a few months before this problem started

    I studied that went through all the troubleshooting steps suggested Microsoft to resolve this issue, but have had no luck... any other help or suggestions would be appreciated. I'm not

    Thank you!!
    Frustrated in minutes

    Install the fixit from article KB2258121 (fixit #50461).

    Although this problem is not mentioned in the KB problem, the fixit indeed solves this problem.

  • HTML (Web), I have a question about the models.

    Hello CC animate developers.

    New features are really good.

    HTML (Web), I have a question about the models.

    <! DOCTYPE html >

    < html >

    < head >

    < meta charset = "UTF-8" >

    < title > $TITLE < /title >

    < meta name = "ad.size" content ="width = $WT, height = $HT" > "

    $CREATEJS_SCRIPTS

    $SCRIPT_START

    var canvas, stage, exportRoot;

    function init() {}

    $CJS_INIT

    }

    $PLAYSOUND

    $SCRIPT_END

    < script type = "text/javascript" >

    "clickTAG" var = "";

    < /script >

    < / head >

    < onload = "init (); the body"style =" background-color: #D4D4D4; " margin: 0px; ">

    < a href = "javascript:window.open (window.clickTag)" >

    < div style = "position: absolute;" cursor: pointer; box-sizing: border-box; border: 1px solid #000000; overflow: hidden; height: $HTpx; Width: $WTpx; Background: rgb (255, 255, 255.0); "> < / div >

    < canvas id = "$CANVAS_ID" width = "$WT" height = "$HT" style = "background-color: $BG" > < / canvas >

    < /a >

    < / body >

    < / html >

    In the example above, the model;

    < Meta name = "ad.siz of" content = "width = $ WTI height = $ HT" > "

    and

    < Div style = "position: absolute;" cursor: pointer; box-sizing: border-box; border: 1px solid # 000000; overflow: hidden; height: $HTpx; Width: $WTpx; Background: rgb (255, 255, 255.0); "> < / div >"

    I use labels. But these tags in the template and import, it gives an error does not occur.

    I think it was a mistake. I want to help in this regard.

    $ HT or Properties $WT , I get an error when I use elsewhere.

    I think I should be able to use anywhere I want.

    The same problem here - I worked around by some DRM models with different values of ad.size, but it's a solution quite short-seight

    Also - you are not able to create the model with transparent background by removing style = "" background-color: $BG ' as it also throws errors - is the only solution that I managed to get updates style = "background-color: $BG; background: none; ", but it's a really bad way of coding things.

    It would be really great to have freedom in changing patterns.

  • PowerCLI script - new virtual machine of the model

    Hi all

    I am very new to power CLI scripting, and these days, that I read a lot of help to automate the creation of a new virtual machine based on the model of the virtual machine.  Script that is not that hard, even location new virtual machine on a particular data and in a particular resource pool store is not difficult.  For this I came up with this very basic script/command:

    "New-VM - ResourcePool < resource_pool > - < folder_name > location - Datastore < datastore_name > - name < VM_name > - < template_name >"model

    However, I came across some problems that I can't find information in help or in the forums.  Problem with the above command is VM will be created in the pool of appropriate resources and file as long as they are unique, but if there are multiple instances of resource pool or a folder with the same name as the script spits out a mannequin.

    So for example if I want to create a new virtual machine to the location following Data_Centre = > RootFolder1 = > SubFolder1 = > SubFolder2 and SubFolder2 name is unique that no problem, the virtual machine is created at this location.  However, if the SubFolder2 exists in Data_Centre = > RootFolder2 = > SubFolder1 as well as the virtual machine is created in the folder root of the location of the model.  For example, if the model is in "DC = > Folder1 = > Subfolder1 = > Subfolder2 ' the virtual machine will be created in the folder Folder1

    Any suggestions on how to ensure that the virtual machine is created in the desired folder/location as well as a list of resources?  In my view, there are really smart guys here and I suspect that this issue would not be a problem at all.  Any help would be appreciated.

    See you soon

    It is not a matter of following the right path.

    You can use the location setting to get the exact folder you want. For example

    $dc = get-data center-name DC1

    $folder = get-file-name Folder1-location $dc

    $subfolder = get-file-name Folder2-location $Folder1

    or

    $dc = get-data center-name DC1

    $subfolder = get-file-name Folder2-location $dc

    You will need to find a "place" in the path to your destination folder where it will be unique.

  • Can I use PowerCLI to delete several photos at the same time?

    I know I can run

    Get - VM | Get-snapshot - name 'Nom_snapshot ' | Remove-Snapshot - confirm: $false

    to delete all the snapshots with a name for the snapshot.  The problem, therefore, 1 at a time, and he's waiting for the first to complete before the kickoff of the next deletion.  Is it possible to have to tell 5 deletions started the same time?  I do all my patch the weekend after Patch Tuesday and the following Mo - I periodically clean snapshots after testing the virtual machine / apps.  I would really just run 1 script and have all removed within a reasonable time.

    Hello

    You can run the cmdlet Remove-snapshot with the parameter - RunAsync, so you don't have to wait earch one.

    More info here: Remove-Snapshot - vSphere PowerCLI cmdlets reference

    Concerning

    Tim

  • upgrade to esxi 4.1 to esxi 4.1 update 1 using powercli

    How to install the update to esxi 4.1 using powercli (powershell?)

    Hello

    The ESXi upgrade could be a problem if the patch file is too large, because there is not enough space in the tmp drive. If you could download the patch on a data store of the host and after this call to the Install-VMHostPatch cmdlet with the HostPath parameter. See the third example here:

    http://www.VMware.com/support/developer/PowerCLI/PowerCLI41U1/HTML/install-VMHostPatch.html

    Vitali

    Team PowerCLI

  • Certificate autoenrollment fails after the update of the model

    Asked me to extend the period of validity on the certificates that we issue to users to authenticate on our wireless LAN. Group Policy allows us to cause users to automatically enroll for a certificate by using a version 3 template (our issuing CA is Windows Server 2003 Enterprise Edition). Users were able to automatically enroll for certificates with no problems.

    To increase the duration of validity, I modified the model certificate as a business administrator (I also increased the renewal period), then forced all certificate holders to re-register, which changed the model on the CA to 101,0 version (previously it was 100.2).

    None of my users seem to be reenrolled for the updated certificate. The search Event Viewer on my PC, I see four 'CertificateServicesClient-CertEnroll' information events (event ID 65, 64 & 66) suggesting that I connect successfully to the issuing certification authority, followed by a source "CertificateServicesClient CertEnroll" error (event ID 13) and error (ID of the event 6) source "CertificateServicesClient-autoenrollment" (details below). This sequence is generated whenever the autoenrollment is triggered.

    Can anyone suggest what could be the problem here? Thank you very much, Damion.

    Log name: Application
    Source: Microsoft-Windows-CertificateServicesClient-CertEnroll
    Date: 18/07/2011 08:44:24
    Event ID: 13
    Task category: no
    Level: error
    Keywords: Classic
    User: domain\user
    Computer: COMPUTER.exe.nhs.uk
    Description:
    Registration certificate for user domain\username could not enroll a certificate WirelessUser with the ISSUINGCA.domain\Issuing CA 19934 request for domain ID (the request template version is newer than the version of the model of support. 0 x 80094807 (-2146875385)).

    Log name: Application
    Source: Microsoft-Windows-CertificateServicesClient-registration auto
    Date: 18/07/2011 08:44:25
    Event ID: 6
    Task category: no
    Level: error
    Keywords: Classic
    User: n/a
    Computer: COMPUTER.exe.nhs.uk
    Description:
    Automatic registration of certificate for domain\user failed (0 x 80094807) the request template version is newer version of model taken in charge.

    This problem has been resolved by a restart of the server.

  • After the model site has changed, how can see what it looked like before that

    Hello

    I posted this question earlier today. My boss was by clicking on the original model and dynamic menus and changed it into force. Now, the menu and submenues changed their position. He doesn't remember exactly what he was doing, but I can't download the current file to compare to my local copy at the moment.

    Anyone suggest a way I can see the preview of what the site looked like the day before yesterday?

    URL: www.preventive.com

    Thank you in advance,

    Anna

    Hi Anna,.

    The menu does not have a rollback or restore function at this point.

    However if the customer has modified the model then it is possible to cancel changes...

    By the intermediary of--> Details page template-> restoration and archiving.

    I hope this helps!

    -Sidney

  • How to change the models of Calc Manager after the migration of HBR

    Hi all

    at the moment I'm trying to migrate a planning application classic migration incl. EPMA to CM business rules. Migration worked well, but I'm a model with CM and I don't like the graphic mode... Is there a way to change (HBR Macros) models in script mode? I can switch mode script for business rules, but I don't see the option if I open a Template (custom template set and after the migration of HBR).

    Thank you very much!
    Kind regards
    André

    P.S.: We are on 11.1.2.1.0

    Currently in 11.1.2.1, it is impossible to set the mode graph script. In the last 11.1.2.2 calc and patch, the default rules of planning will be migrated in order to script. In addition, the model contains a script component that will contain the macro text HBR which you should be able to change. Since the HBR was not deleted in 11.1.2.1, we will not be porting this functionality to 11.1.2.1.

    One thing you can do is to modify the model, remove all graphics components, add a script component, and paste your macro script here. If your model has parameters, you must reference them with []. For example, if the parameter has been param1, then you référenceriez it as [param1] in your macro script.

    Sree - mougel

  • Many of my photos in Lightroom have exclamation points in the upper right corner of the file.  I can't export, modify, or doing something with those photos.  They system (Lightroom) tells me that the files not found

    Many of my photos in Lightroom have exclamation points in the upper right corner of the file.  I can't export, modify, or doing something with those photos.  They system (Lightroom) tells me that the files not found

    Hi Jenny June,.

    Please take a look at the following article, it should be useful: https://helpx.adobe.com/lightroom/help/locate-missing-photos.html

    Kind regards

    Tanuj

  • Determine the use of vCPU using PowerCLI

    Is there a way to determine how many vCPUs uses makes it a virtual machine using PowerCLI?  For example, suppose you try to size just your virtual machines with powerCLI.  If the virtual machine uses several threads, it can use the multiple vCPUs.  If it is mono-thread, it can only use one vCPU even if she has a high workload.  You can determine what virtual machines have multiple vCPUs but use less than they are allocated?

    As much as I know there is no meter that indicates if a core is used or not.

    What you could do, is the use of the CPU, and then check if the assigned processors are required.

    For example, suppose that the average CPU usage is 25%, and the maximum is 50%.

    If this VM has 4 processors assigned, you may deduct 2 CPUs would be sufficient.

    But this isn't an accurate calculation.

    Once you lower the processors assigned to the virtual machine, you will need to see if there's an obvious increase of the ready time.

  • I want to move virtual machines to a folder called Linux name, but we have several file of the same name in our Datacenter, please give me PowerCLI Script to move exactly

    I want to move virtual machines to a folder called Linux name, but we have several file of the same name in our Datacenter, please give me PowerCLI Script to move exactly.

    I tried to use for the function FolderByPath below, but don't know how to use it and have worked. Please help me in this.

    Function Get-FolderByPath {}

    < #.

    . Records of recovery SYNOPSIS by giving a path

    . DESCRIPTION the function will retrieve a record by its

    path. The path can contain any type of leave (folder or)

    Data Center).

    . Author NOTES: Luc relaxing

    . Path PARAMETER

    The path to the folder.

    This is a required parameter.

    . Path PARAMETER

    The path to the folder.

    This is a required parameter.

    . PARAMETER separator

    The character used to separate the leaves in the

    path. The default value is ' / '.

    . EXAMPLE OF

    PS > Get-FolderByPath-path ' Datacenter/Folder1/Folder2 ".

    . EXAMPLE OF

    PS > Get-FolderByPath-path "Folder1 > Folder2"-separator ' > '

    # >

    (param

    [CmdletBinding()]

    [parameter (Mandatory = $true)]

    [System.String []] ${Path}.

    [tank] ${delimiter} = ' / '.

    )

    {in process

    If (((Get-PowerCLIConfiguration).)) DefaultVIServerMode - eq "Multiple") {}

    $vcs = $defaultVIServers

    }

    else {}

    $vcs = $defaultVIServers [0]

    }

    {foreach ($vc to $vcs)

    {foreach ($strPath in $Path)

    $root = get-file-name of the server data $vc centers

    $strPath.Split ($Separator) | %{

    $root = get-inventory-name $_-location $root - server $vc - NoRecursion

    If ((Get-stocks-localisation $root-NoRecursion |)) Select--ExpandProperty name)-contains "vm") {}

    $root = get-inventory-name "vm" - location $root - server $vc - NoRecursion

    }

    }

    $root | where {$_-is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.FolderImpl]}|% {}}

    Get-file-name $_. Name - location $root. Parent - Server $vc

    }

    }

    }

    }

    }

    You can try to retrieve the object file by steps as well.

    Something like this for example

    $folder = get-data center-name 'LTX01-G8 | Get-file-name "LTX-servers | Get-file-name "LTX servers 0000 - 0299. Get-file-name Linux

    I guess the first qualification in your path was the data center.

  • Need help to report on the configurations of the virtual machine using PowerCLI

    Hi guys,.

    I try to shoot down vCenter virtual computer configuration details and am not having much luck with vCPU multicore machines.

    Looking at the lists of VMS in vSphere Client, it offers a column "Number of CPU" basis and does not include any other granularity (i.e. in terms of casings & carrots as opposed to simply 'CPU Count').

    I thought that maybe I have better luck using PowerCLI and essentially, the cmdlet "Get - VM" has the kind of information I'm looking for, but I find that it lacks a bit when it comes to vCPU details.  Essentially, it turns out that does not do much better than the list of virtual machines in vSphere Client because it produces only a "CPU Num" value, which is not particularly useful.

    For example, if "processors Num" 4, that '4' means?  This could mean one of the following:

    • 1 x 4 drivers
    • Core 2 x 2
    • Basic 4 x 1

    I hope someone out there can help produce me a list of virtual machines with details of configuration that includes both sockets & carrots for vCPU?

    Thanks in advance!

    Try like this

    Get-VM | Select Name, @{N="CPU";E={$_.ExtensionData.Config.hardware.numCPU/$_.ExtensionData.Config.hardware.numCoresPerSocket}}, @{N="Core per CPU";E={$_.ExtensionData.Config.hardware.numCoresPerSocket}}
    
  • Automate the VMs using PowerCLI performance report

    Dear Experts,

    I want to automate the monthly performance report (CPU, memory, disk) of the Virtual Machines using PowerCLI or any other script. Basically, I want to do under the tasks mentioned on monthly basis:

    1. use of the CPU (of all virtual machines) statistical average based monthly (as a percentage). Same report for memory (in percent) and the disc (Kbps).

    2. is it possible folderwise? I have several clients in my support infrastructure and I made segregation in making records and for each of them, this report is necessary.

    3. export only these 3 reports in Excel.

    Details of the infrastructure: ESXi 4.0 and 4.1

    Dear Experts, your kind suggestions will be much appreciated? As it takes a lot of time as we do this manually.

    Thank you very much!

    No problem, with the Group-Object cmdlet we can divide the result by VM.

    $metrics = "cpu.usage.average","mem.usage.average","disk.usage.average"
    $start = (Get-Date).AddDays(-30)
    
    $folders = Get-Folder -Location (Get-Folder -Name vm -Location Datacenters)
    # $folders = Get-Folder -Name Folder1,Folder2,Folder3
    &{foreach($folder in $folders){
        $vms = Get-VM -Location $folder    if($vms){
          $stats = Get-Stat -Entity $vms -Stat $metrics -Start $start -ErrorAction SilentlyContinue      if($stats){
            $stats | Group-Object -Property {$_.Entity.Name} | %{
              New-Object PSObject -Property @{
                Folder = $folder.Name            VM = $_.Values[0]
                CpuAvg = ($_.Group | where {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property Value -Average).Average            MemAvg = ($_.Group | where {$_.MetricId -eq "mem.usage.average"} | Measure-Object -Property Value -Average).Average            DiskAvg = ($_.Group | where {$_.MetricId -eq "disk.usage.average"} | Measure-Object -Property Value -Average).Average          }
            }
          }
        }
      }} | Export-Csv C:\report.csv -NoTypeInformation -UseCulture
    

Maybe you are looking for

  • Sony KDL-46EX645 web browser adapter will Flash Player?

    Sony KDL-46EX645 web browser is a not support flash player last year, but someone said that Sony will update their software/hardware for web browser support flash player this year. Sony KDL-46EX645 hdTV web browser now supported flash player of dose?

  • Is Qosmio G20 Vista Premium Ready?

    Windows Vista will be released next year. I have no doubt that the will of the Qosmio G20 Vista capable (races of basic, minimum version of Win Vista), but it will be Premium Ready (run all new applications).I understand everything, but the requireme

  • Star Wars Special Edition Note: This system is not supported

    I need help for the Star Wars content on my laptop special edition of Star Wars.  I had to have my hard drive is erased after it got a virus and for some reason any now when I installed the Star Wars command center it tells me "this system is not sup

  • S3-391 selective startup mode

    New owner of Acer S3 - 391 UltraBook, Windows 8. I noticed that when I go in "System Configuration" that he is in default of payment to "Selective startup" and I can't change the setting of "Normal startup". I can select the 'Normal' radio button and

  • Printer properties cannot be displayed. The print spooler is not running.

    I followed the MS KB "file sharing and printers with different versions of Windows" for instructions on connecting my new Win 7 PC to several domestic XP PC in my network. However, once that I had on the right by clicking on the printer for XP to sha