With 4.1 vSphere PowerCLI
I get an error when I try to use a customization of OS colleagues. If I remove it, the clone succeeds. Any help would be greatly appreciated.
PowerCLI C:\ > new-VM - VM $sourceVM - name PowerClone2 - OSCustomizationSpec $spec
fication Datastore - $datastore - vmhost $VMHost
New - VM: 13/03/2012 10:59:41 New - VM is not a valid Win32 application
on. (Exception from HRESULT: 0x800700C1)
Online: 1 character: 7
+ New-VM < < < < - VM $sourceVM - name PowerClone2 - OSCustomizationSpec $specifica
tion - Datastore $datastore - vmhost $VMHost
+ CategoryInfo: NotSpecified: (:)) [new-VM], VimException)
+ FullyQualifiedErrorId: Core_BaseCmdlet_UnknownError, VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.NewVM
Yes, see this Technical Document
And there is an Intro and a reference using VMwareView.
Tags: VMware
Similar Questions
-
Using Windows Powershell ISE with vSphere PowerCLI
Hey everybody,
I'm completely newbieand have just started on the track "managing vSphere with powershell. First problem:
Is it possible to use Windows Powershell ISE with vSphere cmdlets or can I only use the vSphere PowerCLI?
I wish I could type my commands directly in the window of the ISE and manage my scripts etc because of this (I find myself n always cut and paste from Notepad when you use the PowerCLI).
If so, how should I do this?
I guess its something simple, but when I run the ISE seems not to have registered vSphere cmdlets. I guess I missed something?
Thank you
Marc
In the ISE if you run the following cmdlet, you will get the registered PowerCLI cmdlets:
Add-PSSnapin "Vmware.VimAutomation.Core".
-
Addition of VMDK to VM in new vSphere PowerCLI
Hi all
This message goes hand in hand with may last post and involve the transfer of uncomfortable the new vSphere PowerCLI from the VItoolkit on VMware 3.5.
One of my scripts uses some functions to add existing VMDK files on an existing virtual machine. The big problem is - this code is a reason any invalid in the CLI of new power.
As you can see - functions have simple command line with VM, VMDK file and the number of SCSI controller. Can someone hazard a guess then that this process is no longer valid for PowerCLI?
Thank you in advance: o)
Functions
# #Examples
Add HD "PC4" "vmfs2" "PC4/PC4.vmdk" "controller SCSI 0".
VM-delete-HD 'name' "disk hard 3" $TRUE ".
function add-HD {}
Param ($VMname, $SCSIcntrl, $DSname, $Filename)
#write - host "adding disc $Filename data $DSname $VMname-VM store."
$vm = get - View (Get - VM $VMname) USER.USER
$ds = get - View (Get-Datastore-name $DSname) USER.USER
{foreach ($dev to $vm.config.hardware.device)}
If ($dev.deviceInfo.label - eq $SCSIcntrl) {}
$CntrlKey = $dev.key
}
}
$Unitnumber = 0
$DevKey = 0
{foreach ($dev to $vm.config.hardware.device)}
If ($dev.controllerKey - eq $CntrlKey) {}
If ($dev. Unitnumber - gt $Unitnumber) {$Unitnumber = $dev. Unitnumber}
If ($dev.key - gt $DevKey) {$DevKey = $dev.key}
}
}
LogEntry $sLogFile 'DeviceKey is $DEVKEY, UnitNUm is $UnitNUmber, ContrlKey is $CntrlKey.
$spec = new-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = @)
$spec.deviceChange += new-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange [0] = new-Object VMware.Vim.VirtualDisk .device
$spec.deviceChange [0].device.backing = new-Object VMware.Vim.VirtualDiskFlatVer2BackingInfo
$spec.deviceChange [0].device.backing.datastore = $ds. MoRef
$spec.deviceChange [0].device.backing.fileName = "" + $Filename
$spec.deviceChange [0].device.backing.diskMode = "independent_persistent".
$spec.deviceChange [0].device.key = $DevKey + 1
UnitNUmber SCSIID 7 is reserved for the controller - so ignore it and move on to 8.
If ($Unitnumber - eq 6) {$Unitnumber = $Unitnumber + 1}
$spec.deviceChange [0].device.unitnumber = $Unitnumber + 1
$spec.deviceChange [0].device.controllerKey = $CntrlKey
$spec.deviceChange [0] .operation = 'Add '.
$vm. ReconfigVM_Task ($spec)
}
delete-HD {} feature
Param ($VMname, $HDname, $Delflag)
#write-host "' disassembly disk for VM $HDname: $VMname" "
$vm = get - View (Get - VM $VMname) USER.USER
foreach ($dev in $vm. Config.Hardware.Device) {}
If ($dev. DeviceInfo.Label - eq $HDname) {}
$key = $dev. Key
$name = $dev. Backing.FileName
}
}
$spec = new-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = @)
$spec.deviceChange += new-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange [0] = new-Object VMware.Vim.VirtualDevice .device
$spec.deviceChange [0].device.key = $key
$spec.deviceChange [0] .operation = 'delete '.
$vm. ReconfigVM_Task ($spec)
If {($Delflag)
$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = 'ServiceInstance.
$svcRef.Value = 'ServiceInstance.
$serviceInstance = get-views $svcRef
$fileMgr = get-view $serviceInstance.Content.fileManager
$datacenter = (get-View (Get - VM $VMname |)) Get-Datacenter) USER.USER) .get_MoRef)
$fileMgr.DeleteDatastoreFile_Task ($name, $datacenter)
}
}
Below the new versions of my HD - Add and Remove-HD functions.
The functions Add - HD had an error in this line
$spec.deviceChange[0].device.backing.fileName =" " + $Filename
The function Remove-HD can be optimized in vSPhere.
With the help of the LayoutEx.Disk property, you can now find all the files that are located behind a virtual disk.
The new versions are attached because there are some hooks in the code.
-
Restore with replication of vSphere
Hello
We use SRM 5.1 with replication of vSphere.
I'm trying to get a rough idea of how long a reprotect operation would take after a failover, especially synchronization of storage.
The manual says that:
"The full synchronization that appears especially in the stages of recovery performs control totals, and only a small amount of data is transferred over the network."However in my testing this step still seems to take a long time to complete. For a person of 50 GB, it takes 40 minutes. My question is: what is the bottleneck here and I can speed things up?
In a live scenario, I have much larger comments VMs and I fear that a reprotect could take days to synchronize the storage.
Thank you
Steve
The full synchronization bed basically just for the disk data and checksum data. It also makes requests to read the data and return a set of checksums remotely. He would only send the data if the checksums do not match. Thus, assuming that not many disk changed, there is very little except checksum travel over the network. So you will respect especially how fast you can read files vmdk on both sites and to a lesser extent by the latency of the network between the sites, and, of course, if the link between the sites remains upward.
Check if the link to the sites is good. Get often ignored or not connections are limited somehow? The latency is extremely high, as hundreds of milliseconds? This can slow things down.
On the source site, make sure that the storage is not overloaded with other work. In the case of NAS/ISCSI, check also that there is no other work of network hogging bandwidth. Sometimes, there are periodic offers on secondary sites, like backups, and that people often forget this can be a lot of resources.
On the destination site, carry out similar checks and make sure that the server VR is to get a reasonable amount of network and CPU resources.
-
Cannot download - VMware vSphere PowerCLI for tenants
Hi people,
I'm not able to download VMware vSphere PowerCLI for the R2 version of tenants i.e. 5.1. Go to the page cannot be displayed.
Please check.
Kind regards
Rajesh
VMware vSphere PowerCLI for tenants
Seems to work for me from this link.
Perhaps a local cache in your browser problem, or a problem of Akamai in your area?
-
Auto open when you click on VMware vSphere PowerCLI icon.
Hello
Quick question is there a configuration file or a way for me to have powershell cli automaticly "connect-viserver" when I open the icon "VMware vSphere PowerCLI.
Thank you
There are several ways to achieve this.
The best way, in my humble opinion, is to add the Connect-VIServer cmdlet to a PowerShell profile files.
Just add a line to the file. If you use an authorized account, you can do
SE connect-VIServer-Server MyServer
I suggest you use the profile of the current user, in this way that the Connect-VIServer will run only when you start PowerCLI
-
Recovery of vSphere PowerCLI with alarms
Hello
Can you please help me write a PowerCLI script that would recover the vSphere alarms?
I want the script to show only alarms last 24 hours only if not acknowledged or deleted.
Example:
Get-VIEvent - MaxSamples 10 | Select Fullformattedmessage # this command shows me the last 10 events
Win01 from green to Red alarm # the script "MyAlarm" should show me this alarm
win01 on esx1.company.pri in Lodz is turned off
win01 on esx1.company.pri in Lodz stops
Task: Stop virtual machine
win01 on esx1.company.pri in Lodz is turned on
Message on win01 on esx1.company.pri in Lodz: running VMware ESX in a virtua...
starts win01 on the host esx1.company.pri in Lodz
Task: Power on virtual machine
Task: Initialize turn
Alarm"monitor the health status"on changed from yellow to green data centers.
Help, please.
If the alarm was not recognized and authorized, it should still show.
You can see these alarms with
$dc = get - file - name of data centers
$dc. ExtensionData.TriggeredAlarmState |
Select @{N = 'Entity'; E = {Get-view-Id $_.} Entity | {{Select - ExpandProperty name}}.
OverallStatus,
@{N = "alarm"; E = {(Get-View-ID $_.)} Alarm). Info.Name}}
-What are you looking for?
-
I'm trying to generate a report of all snapshots in the ESX environment.
(1) installed PowerShell 2.0 for Windows XP
(2) installed VMware PowerCLI 4.0 U1
(3) installed VMware VI Toolkit for Windows 1.5
(4) added PSSnapin VMware.VimAutomation.Core
(5) any module viToolkitExtensions.psm1 version 74794
(6) found recommended community command of the ' Get - VM | Get-TkeSnapshotExtended | Select Name, VM, SizeMB '.
It does not work! However powershell returns the following error between each instant result:
Member add: unable to add a member with the name "SizeMB" because a member with the same name already exists. If you want
replace the Member anyway, use the Force parameter to overwrite.
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\viToolkitExtensions\viToolkitExtensions.psm1:2453 tank: 20
+ $s | Add-Member < < < < - type noteproperty - name "SizeMB" - value ($totalSize / 1 mb)
+ CategoryInfo: InvalidOperation: (% 2f14% 2f2010 o7: PSObject) , InvalidOperationException
+ FullyQualifiedErrorId: MemberAlreadyExists, Microsoft.PowerShell.Commands.AddMemberCommand
Does anyone know what causes this or how to fix?
The problem you see is that the object returned by
Get-VM
| Get-Snapshot already contains a property named SizeMB in PowerCLI 4u1.
The simplest solution is to comment out this line in the file viToolkitExtensions.psm1, like this
# Add this to the input object and pass it through. # $s | add-member -type noteproperty -name "SizeMB" -value ($totalSize / 1mb) $s
But in fact the Extensions community complete need for a review.
With PowerCLI 4.1 module does not at all since all object types have been modified.
BTW, there is no need to install VI Toolkit 1.5 and PowerCLI 4.0u1. The two are different versions of the same product.
The confusion probably comes from the name change that occurred when PowerCLI 4.0 was released.
____________
Blog: LucD notes
Twitter: lucd22
-
need help with first vsphere powercli script
Greetings,
Asked me to write a script to iterate over all the virtual machines in a given folder and to stop. The name of the folder is blue (and is deep in several files).
So far, I have:
$svr = Connect-VIServer-Server svr-protocol https-user--password...
$fldr = get-file-server $svr - blue name
I don't know what to do next. I would like to somehow get a picture of the VMS in the Blue folder, and then run:
{foreach ($vm to $vmlist)
Get - VM $vm | Stop-VMGuest
}
How can I do this? Ideally, it should be wrapped in a function that I could pass the name of the file, because I really need to stop the virtual machines in the blue folder and a few others, too.
Any help would be greatly appreciated.
Thank you
-John
You can specify the file on the location of the Get-VM cmdlet parameter.
Something like that
foreach( $vm in (Get-Vm -Location (Get-Folder Blue)) { $vm | Shutdown-VMGuest }
In PowerShell and PowerCLI, there is of course more then a way to get there.
It should work as well
Get-Folder Blue | Get-VM | %{ Shutdown-VMGuest -VM $_ }
____________
Blog: LucD notes
Twitter: lucd22
-
Need help to update to work with the new vSphere environment 6
I have a great powershell script some time ago, I created to clone our production servers in a development environment and configure them for use in isolated vShield development networks.
We have recently updated our environment vSphere vSphere 6 and changed architecture autour 5.
Previously with vSphere 5 we had a unique vCenter server that managed our two datacenters by itself.
With the new design of vSphere 6, we have a PSC and VCSA server to each data center in one area of SSO.
The first thing I did with my script of cloning is up-to-date reference vcenter for a table of two servers, so I connect to two VCs at the same time.
This allows me to see and manage the two vCenters virtual computer guests, so get - vm strives to see the comments of the source.
However, the problem is that when I try to clone a virtual machine from one data center to another, the command fails because it can't find the virtual machine to clone.
# Virtual Centre server or VM host to connect to $aryVIServer = @("vc01.domain.com", "vc02.domain.com") # Load VMware environment Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -InvalidCertificateAction Ignore -Confirm:$false | Out-Null $VIServer = Connect-VIServer $aryVIServer # Server cluster group to deploy to $strVMCluster = "Bubbles" # Define name of new server including environment prefix $vmName = "$($envPrefix)-$($CloneServer)" # Select Host with least memory consumption $selectedHostObj = Get-VMHost -Location $strVMCluster | Sort-Object -Property MemoryUsageGB | Select-Object -First 1 # Select folder to place VM guest into $folderObj = Get-Datacenter -Cluster $strVMCluster | Get-Folder $selectedBubble # Select datastore with most available space $selectedDatastoreObj = Get-DataStore -VMHost $selectedHostObj | Sort-Object -Property FreeSpaceGB -descending | Select-Object -First 1 # Clone new VM from running Server $newVM = New-VM -Name $vmName -VM $CloneServer -VMHost $selectedHostObj -Datastore $selectedDatastoreObj -DiskStorageFormat "Thin" -Location $folderObj -Confirm:$false
He used to work very well when there was a single VC but of course does not now with two.
So far, the only difference is the change in VCs. We always use the same exact 5.0 running ESXi hosts to the same place in separate data centers.
Oh and I'm now using powercli 6.3 R1 instead of 5.5 R1.
I look forward to this type of procedure should work fine, and I just need a different command for virtual machine cloning now?
Well, I have solved the first problem according to them here:
Re: Impossible to deploy VM model on different vCenter Server (in the same domain of SINGLE sign-on)
However, now I can't run Invoke VMScript without getting an error that the proxy authentication is required.
If I remove all my proxy settings in Internet Explorer, then it connects fine but this script must be run by a number of engineers without being dependent on their proxy settings are disabled.
I can programmatically change the settings of proxy at the beginning of the script, but nothing not preventing to change those back if they use their browser and break execution of the halfway of script.
Never had any problems with the Proxy settings before and I didn't know any other messages that have directly relevant air.
Anyone know of a way to avoid this?
-
vSphere PowerCLI - of different values on the Allocation of resources and 5.1
Hello
I have a situation where I was trying to follow in one of our virtual machines that could miss the unlimited check mark on the allocation of memory to the title resources. In doing so, I was in a situation where powerCLI shows values different vsphere for memory and cpu shares until I removed and add the check unlimted box and clicked on OK.
I guess my question is double.
1. How will I know if the virtual machine variety is actually being allocated resources properly when there is this difference.
2. If it's just a property not being pulled to the PowerCLI correctly I presume I can ignore it? If this isn't the case, you know another way to have it acknowledged correctly so I must not go through a hundred servers again and manually perform this procedure.
Finally, if there is a real problem with the assigned resources hurt if I go through this process and now everything gets double maybe will we have problems with guests not being is not able to manage the new distributions?
That's what it looks like, top is a bad server and down is a server has been fixed.
Name: Server01
MemoryMB: 4096
NumCpu: 2
VMResourceConfiguration: CPUShares: Normal / 1000 MemShares: Normal / 25600
Name: Server02
MemoryMB: 4096
NumCpu: 2
VMResourceConfiguration: CPUShares: Normal / 2000 MemShares: Normal / 40960
Hope it makes sense.
Thanks for any idea you may have.
Shane
PS... is it just me (IE11) or can't you copy and paste in the editor on this community?
There is indeed a minor flaw in the value of the shares shows PowerCLI.
To begin with, what you get for fixed levels are well documented.
See the distributions of resources
Which can be seen in the vSphere for a VM client
It is a virtual machine that has 2 vCPU (2 x 1000)
The cmdlet Get-VMResourceConfiguration to the PowerCLI returns the value that is actually in the VirtualMachine object.
This value does not seem to take into account the fact that the virtual machine has 2 vCPU, while the vSphere client does not seem to take into account of the # of vCPU.
You can check by doing
Get - VM MyVM | Select the Name,@{N="CPU actions; E={$_. ExtensionData.Config.CpuAllocation.Shares.Shares}}
However, if the level of shares is not personalized, the SDK Reference tells us "that if the level is not set to custom, this value is ignored."
See SharesInfo
In conclusion, the cmdlet PowerCLI is correct, it returns the value that is there, but this value is irrelevant unless the level is set to Custom.
PS: I seem to have no problem to copy and paste in the editor.
Have you tried with another browser?
-
What to buy to use vSphere PowerCLI
Hello
I'm kinda new on ESX but used PowerCLI at length in the last six months.
However, I have trouble understanding what I have to put in place infrastructure vSphere, however small, at home; specifically, if I want to use PowerCLI.
What should I buy to run ESX on one or two hosts and use vCenter and PowerCLI to administer guests? The "Essentials" kit made it? What license do I need? I see that I can download PowerCLI, but will it work with any installation ESX or vSphere?
Please notify.
Thank you.
What should I buy to run ESX on one or two hosts and use vCenter and PowerCLI to administer guests? The "Essentials" kit made it? What license do I need? I see that I can download PowerCLI, but will it work with any installation ESX or vSphere?
Unfortunately, VMware has decided to lock automation ESXi API accessed by PowerCLI and other tools, while the API is read-only on ESXi hosts running with the license free "vSphere Hypervisor. You can always perform 'read' operations such as Get - VM or Get-VMHost, but everything 'written' with Set-* Add-* New-* Remove-* cmdlets etc will not work with the free license.
Any official license is sufficient to lift this limitation, so you can get the kit of essentials at low cost. Of course you are still bound by the limitations of features General this license then well.
Another great option would be that you re - build your laboratory every 60 days with evaluation licenses.
-
Alert shadow in vSphere PowerCLI script
Hi all
I have been using the script from this site with great success.
http://vnucleus.com/2011/07/PowerCLI-script-to-alert-on-snapshots-in-vSphere/
What I'm trying to understand it how to change the script, then he will send a report, even if there are no snapshots on virtual machines?
Can you get it someone please let me know what I should do?
Thank you
Ray
Some
is lost during the copy/paste, it seems. I've corrected the above lines, please try again.
-
Hi all
[1]
PowerCLI v4.1.1 will work with vSphere 5?
[2]
Released PowerCLI v5? If so when? If not, why?
marc0
marc045,
Some cmdlets in PowerCLI 4.11 will be the same and will work with vSphere 5.0, but it is recommended that you upgrade to the latest version of PowerCLI as soon as vSphere 5.0 was released, you will see a coresponding version once vSphere 5.0 was released.
VMware have not given a release date yet for 5.0
Alan Renouf
-
Disaster recovery with replication for VSphere
Am just test VSphere 5 of replication. with a couple of test VMs
The replication process works very well
What I want to know is the process to recover a VM replicated to new hardware in the case of the complete failure of the original host and/or data store
In essence, disaster recovery.
Are there other parts (software), that I need to take the replica VMDK and files related to re - create a new virtual machine on a new host
Steve
Yes, because it will be all your hard and .vmx files.
Maybe you are looking for
-
How to set the APN settings manually? If you could add pictures is simple
I work in cellular technical support and we don't how to configure APN Firefox OS.I asked to explain to me how you do that.Thanks for help.
-
N40l Microserver does not illuminate. Switch will not do anything.
Team, I have a micro N40L server that I use a home theater media server. It has been sitting in my living room for a few years, quite happy. This week, possibly after a power failure, the server couldn't start. I noticed he was sitting there with the
-
The start page is glued on its tab and will only change the size with an arrow of sliding between the tongue and the following.
-
Satellite L875D: There is possibility to enable virtualization in the BIOS?
Hello I want to buy Toshiba L875D-S73. I know supports CPU AMD - V required for the performance of like Microsoft Hyper-V virtualization.But I don't hear anything about BIOS. Is - this ability to enable virtualization in the BIOS?Maybe you know?
-
I intend to buy 6s in Saudi Arabia.
I intend to buy 6s in Saudi Arabia. I read that the face time is forbidden / not available in Saudi Arabia. But I saw a promotion of a famous store they sell the iphone with face time. Can someone explain, I'll buy that or if it is better to buy it?