-Confirm:$false
$vcs = @()
$vcs += connect-viserver <VC 1>
$vcs += connect-viserver <VC 2>
...
$vcs += connect-viserver <VC N>
# Snapshot all VMs across all VirtualCenter servers.
get-vm -server $vcs | new-snapshot
connect-viserver -server <server> -user <user> -password <pwd>
connect-viserver -server <server> -user <user> -password <pwd> -port <port>
New-VM -Name "Target-VM" -Host (Get-VMHost)
connect-viserver -server <server> -user <user> -password <pwd>
$datastore = Get-Datastore -Name "Select-Datastore-Name"
New-VM -Name "Target-VM" -Host (Get-VMHost -Datastore $datastore)
connect-viserver -server <server> -user <user> -password <pwd>
# If importing to a cluster uncomment the line below
# $rp = get-cluster <cluster name> | get-resourcepool | get-view
# If importing to a non-cluster host uncomment the line below
# $rp = get-vmhost <host name> | get-resourcepool | get-view
$vmFolder = get-view (get-folder vm).id
$vmFolder.RegisterVM_Task("[<Datastore Name>] <Path To VMX>.vmx", "<VM Name>", $false, $rp.MoRef, $null)
connect-viserver -server <server> -user <user> -password <pwd>
Write-Output "FloppyDrive Status:"
Get-vm | Select-Object @{ Name="Status"; Expression={(Get-FloppyDrive -VM $_).ConnectionState.Connected}}, @{ Name="Name"; Expression={$_.Name}} | ft
Write-Output "CDDrive Status:"
Get-vm | Select-Object @{ Name="Status"; Expression={(Get-CDDrive -VM $_).ConnectionState.Connected}}, @{ Name="Name"; Expression={$_.Name}} | ft
connect-viserver -server <server> -user <user> -password <pwd>
$vm = Get-View (Get-VM VMName).Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$vm.ReconfigVM($vmConfigSpec)
connect-viserver -Server <Server> -User <user> -Password <password>
$vm = Get-VM VMName | % {Get-View $_.ID}
$spec = new-object VMware.Vim.VirtualMachineConfigSpec
$spec.CPUAllocation = New-Object VMware.Vim.ResourceAllocationInfo
$spec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo
$spec.CpuAllocation.Shares.Level = "normal"
$spec.CpuAllocation.Limit = -1
$vm.ReconfigVM_Task($spec)
connect-viserver -Server <Server> -User <user> -Password <password>
get-vm VMName | % { get-view $_.ID } | select Name, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}}
connect-viserver -server <server> -user <user> -password <pwd>
$vmclonespec = New-Object VMware.Vim.VirtualMachineCloneSpec
$vmclonespec.Customization = New-Object VMware.Vim.CustomizationSpec
$vmclonespec.Customization.NicSettingMap = @(New-Object VMware.Vim.CustomizationAdapterMapping)
$vmclonespec.Customization.NicSettingMap[0].Adapter = New-Object VMware.Vim.CustomizationIPSettings
$vmclonespec.Customization.NicSettingMap[0].Adapter.ip = New-Object VMware.Vim.CustomizationFixedIp
$vmclonespec.Customization.NicSettingMap[0].Adapter.Ip.IpAddress = "<Target IP Address>"
$vmclonespec.Customization.Identity = New-Object vmware.Vim.CustomizationIdentitySettings
$vmclonespec.Customization.GlobalIPSettings = New-Object VMware.Vim.CustomizationGlobalIPSettings
$vmclonespec.config = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmclonespec.location = New-Object VMware.Vim.VirtualMachineRelocateSpec
$vmclonespec.powerOn = $false
$vmclonespec.template = $false
$name = "Test"
$target = Get-Folder -Name TARGETFOLDER | % {Get-View $_.ID}
$vmmor = Get-VM VMNAME | Get-View
$vmmor.CloneVM_Task($target.MoRef ,$name, $vmclonespec )
connect-viserver -Server <Server> -User <user> -Password <password>
get-vmhost ESX1 | get-vm namevm | move-vm &ndash;destination (get-vmhost ESX2)
connect-viserver -server <server> -user <user> -password <pwd>
New-Snapshot -Name &ldquo;Target-Snpsht&rdquo; -VM (Get-VM)
connect-viserver -server <server> -user <user> -password <pwd>
$vm = Get-VM -Name &ldquo;VMName&rdquo;
$snapshotname = $vm | Get-Snapshot -Name &ldquo;Target-Snpsht&rdquo;
$vm | get-snapshot -Name &ldquo;Target-Snpsht&rdquo; | where { $_.name -like $snapshotname.name } | %{ set-vm $vm -snapshot $snapshotname }
connect-viserver -server <server> -user <user> -password <pwd>
Get-VM | Get-Snapshot | Where { $_.Created -lt (Get-Date).AddDays(-30)} | select Name, Created
connect-viserver -server <server> -user <user> -password <pwd>
Get-VMHost YOURHOST | New-VirtualSwitch -name "My New Switch" -nic YOURNIC (e.g. vmnic1)
Get-VMHost YOURHOST | Get-VirtualSwitch -name "My New Switch" | New-VirtualPortGroup -vlanid 100
connect-viserver -server <server> -user <user> -password <pwd>
$HS = Get-VMHost YOURHOST | get-view
$dtsystem = $HS.ConfigManager.DateTimeSystem
$mor = Get-View -MoRef $dtsystem
$dateConfig = New-Object Vmware.Vim.HostDateTimeConfig
$hsntpConfig = New-Object VMware.Vim.HostNtpConfig
$dateConfig.ntpConfig = $hsntpConfig
$dateConfig.ntpConfig.server = @("<Your NTP Server>")
$dateConfig.timeZone = "<Your Timezone>"
$mor.updateDateTimeConfig($dateConfig)
connect-viserver -server <server> -user <user> -password <pwd>
get-vmhost | Get-VMHostStorage -RescanAllHBA
connect-viserver -server <server> -user <user> -password <pwd>
Get-VMHost | % {Get-View $_.ID} | % {$_.name; $nics = $_.config.network.pnic; foreach ($nic in $nics){$nic.device}}
connect-viserver -server <server> -user <user> -password <pwd>
# $nics will hold an array of physical NICs on the server.
$nics = (get-vmhost | get-vmhostnetwork).PhysicalNic
$nics | where { $_.DeviceName -eq "NIC_TO_CONFIGURE" } | Set-VMHostNetworkAdapter -duplex full -bitratepersecmb 100
connect-viserver -server <server> -user <user> -password <pwd>
$HS = Get-VMHost YOURHOST | get-view
$HS.ShutdownHost("false")
connect-viserver -server <server> -user <user> -password <pwd>
get-vm | % { get-view $_.ID } | Select-Object Name, @{ Name="MemoryMB"; Expression={$_.Summary.Config.memorySizeMB}} , @{ Name="MemReservation"; Expression={$_.Summary.Config.memoryReservation}} , @{ Name="numCpu"; Expression={$_.Summary.Config.numCpu}} , @{ Name="numVirtualDisks"; Expression={$_.Summary.Config.numVirtualDisks}}
connect-viserver -server <server> -user <user> -password <pwd>
Get-Folder vm | New-Folder -Name &ldquo;Target-Folder-Name&rdquo;
$vmsToDisableInvoke = Get-VM <vms to reconfigure>
$vmsToDisableInvoke | foreach {
$vm = Get-View $_.Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[0].Key="monitor_control.restrict_backdoor"
$vmConfigSpec.extraconfig[0].Value="true"
$vm.ReconfigVM($vmConfigSpec)
}
I've also seen this error.
I'm not sure whether this process is one to clone a VM, setting the IP address required, or one that can be used to reset the IP address of an existing machine. It would be helpful if this could be made clear. Could someone advise on this?
In any event, some additional parameters that might be helpful are:
$vmclonespec.Customization.NicSettingMap[0].Adapter.Ip.IpAddress = "1.1.1.1"
$vmclonespec.Customization.NicSettingMap[0].Adapter.SubnetMask = "255.0.0.0"
$vmclonespec.Customization.NicSettingMap[0].Adapter.Gateway = "1.1.1.254"
$vmclonespec.Customization.NicSettingMap[0].Adapter.DnsServerList = "2.2.2.2"
Where is the Server 2008 support for this great tool?
With regards to the Changing IP Address Script. Has anyone seen the error "A specified paramater is was not correct spec.identity" Anyone have any solutions or ideas?