Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 192300

Re: Using Powercli I having trouble modifying vm hardware and nic portgroup when deploying from template

$
0
0

ok, So i ran this

 

Import-Csv deploy.csv -UseCulture | %{      function UpdateVMSettings {      Write-Host "Changing Portgroup and virtual Hardware..."      Get-OSCustomizationSpec $_.Customization | Set-OSCustomizationSpec -MemoryMB $_.MemoryMB -NumCpu $_.NumCpu -Confirm:$false    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      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      }            $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" -Datastore $_.Datastore -OSCustomizationSpec $_.Customization -Confirm:$false -RunAsync     Get-VM -Name $_."Server Name" | Get-NetworkAdapter | Where {$_.NetworkName -eq 140 } |Set-NetworkAdapter -StartConnected:$true -Connected:$true -NetworkName $_.VLAN -Confirm:$false    }

 

But I get this error

 

Get-VM : 7/7/2013 10:44:59 PMGet-VM    VM with name 'testserver01' was

not found, using the specified filter(s).

At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\works\

VMs\test.ps1:10 char:11

+ Get-VM <<<<  -Name $_."Server Name" | Get-NetworkAdapter | where { $_.Pos

ition -eq '1'} | Set-NetworkAdapter -StartConnected:$true -Connected:$true -Net

workName $_.VLAN -Confirm:$false

+ CategoryInfo      : ObjectNotFound: (:) [Get-VM], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimA

   utomation.ViCore.Cmdlets.Commands.GetVM

.

Seems like the server is not ready yet for the changing of the network name because it can't find the server name yet.


Viewing all articles
Browse latest Browse all 192300

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>