PowerCLI script necessary comments and storage.
Hello
I was wondering if someone can help me with a script. I'm looking for a script that will list all guests in a vCenter and their storage.
Thank you in advance,
Something like that?
Get-VM | %{ $vm = $_ $vm | Get-HardDisk | Select @{N="VM";E={$vm.Name}},Name, Capacity,Storageformat,Persistence,Filename }
Or are you looking for other properties to storage?
____________
Blog: LucD notes
Twitter: lucd22
Tags: VMware
Similar Questions
-
PowerCLI script start vm and check the boot
Hello
I try to do a powercli script to start the virtual machine and check when the (windows) operating system is completely open and ready.
How can I do?
Maybe this helps...
Start-VM - VM
- runAsync $vm = get - vm
Start-Sleep - seconds 20;
$vm | Get-VMQuestion | Game-VMQuestion - version - confirm: $false;
do
{
Start-Sleep - seconds 5;
$toolsStatus = $vm.extensionData.Guest.ToolsStatus;
} While ($toolsStatus - not "toolsOK");
-
Change the PowerCLI Script to use the DRS and DRS storage
Hello
I have a PowerCLI script that specifies a host and a data store to create a new virtual machine, which has served us well. Now we have activated the DRS and DRS storage and I wonder what to change in order to take advantage of these features. Are there commands to specify a cluster and the cluster data store and let the DRS to decide the initial investment for a new virtual machine? At the moment we put all hosts and the warehouses of data as variables and use them in the line below.
Thank you.
$newVM = New-VM-name $NewVMname - VM $TemplateName Datastore - $datastore - VMHost $vHost - confirm: $false - location $myName
You set a Datastorecluster?
If Yes, then you can replace the value of parameter data with the datastorecluster object store.
Replacing a VMHost with a cluster is not taken in charge I'm afraid.
But you can use something like this
New-VM-name TestVM Datastore - DSC - ResourcePool (Get-Cluster-name mycluster |) Get - Resourcepool - name of resources)
This will automatically select the VMHost.
The virtual machine appears in the root of the cluster.
DSC is the name of a datastorecluster in the cluster mycluster
-
Hi all
If someone can help me with a powercli script to create a new account a local administrator on all ESX and ESXi hosts in the vcenter, create a role called admin and give all access except the root. This shoulb be past by a virtual centre.
Very much appreciated to help him.
Kind regards
MelLvin
I suspect that you posted your question to the wrong thread
This requires only a minor change to the script above actually.
Something like that
$groupName = "group"$accountName = "user"$accountPswd = "password"$accountDescription = "A user" $esxlist = Get-VMHostforeach($esx in $esxlist){ Connect-VIServer -Server $esx -User root -Password "password" Try { Get-VMHostAccount -Id $groupName -Group -ErrorAction Stop | Out-Null } Catch { New-VMHostAccount -Id $groupName -GroupAccount | Out-Null } $rootFolder = Get-Folder -Name ha-folder-root Try{ $account = Get-VMHostAccount -Id $accountName -ErrorAction Stop | Set-VMHostAccount -Password $accountPswd -Description $accountDescription -AssignGroups $groupName } Catch{ $account = New-VMHostAccount -Id $accountName -Password $accountPswd -Description $accountDescription -UserAccount -GrantShellAccess -AssignGroups $groupName } $rootFolder = Get-Folder -Name ha-folder-root New-VIPermission -Entity $rootFolder -Principal $account -Role admin Disconnect-VIServer -Confirm:$false}
-
Hi all
I checked a few posts on the migration to the new vCenter Server virtual machine. But I'm not very good with Powercli and need some help here.
We have a new vCenter server where we migrate virtual machines from one source vCenter server. Here are two things that I don't know how to connect together to make sure that bwfore we turn on the virtual machine to the virtual machine is connected to its source network.
Part 1 - this script works well but do not get any network on the vCenter destination.
cluster = Get-Cluster "clusterA.
$inventory = get-Cluster $cluster | Get - VM | Add-Member - MemberType ScriptProperty-name "VMXPath" - value {$this.extensiondata.config.files.vmpathname}-Passthru-Force | Select-Object Name ResourcePool, folder, VMXPath |
$inventory | Export-Csv c:\file.csv
$inventory = import-csv c:\file.csv
$cluster = get-group 'b '.
{foreach ($vm to $inventory)
$ESXHost = get-Cluster $cluster | Get-VMHost | Select - 1 first
New-VM - VMFilePath $vm. VMXPath - VMHost $ESXHost - location $vm. Folder - ResourcePool (Get-Cluster $cluster |) Get-ResourcePool $vm. ResourcePool)
}
Part 2 - I want to preserve the Portgroup macaddress and the Ip of the virtual computers and connect them to the new vCenter. How can I do this with the script below. Or how can I combine them together?
$vm_list = get-Cluster-name "clustera | Get - VM test * | Name sort
$information = {foreach ($vm to $vm_list)
$network_adapter_information = get-NetworkAdapter - VM $vm
$vm | Select Name,PowerState,ResourcePool,@{N="Path; E= {$_. ExtensionData.Summary.Config.VmPathName}},@{N="NetworkAdapter '; E = {[string]: join (":", ($network_adapter_information |))} %{$_. {{(Nom + "," + _.NetworkName $}))}}, @{N = "MacAddress"; E = {[string]: join (",", ($network_adapter_information | % {$_.}))} MacAddress}))}}
}
Step 2
# Unsubscribe virtual machines
Remove-VM - VM $vm_list-RunAsync Verbose - confirm: $false
Step 3
$cluster = get-group 'b '.
{foreach ($vm to $inventory)
$ESXHost = get-Cluster $cluster | Get-VMHost | Select - 1 first
New-VM - VMFilePath $vm. VMXPath - VMHost $ESXHost - location $vm. Folder - ResourcePool (Get-Cluster $cluster |) Get-ResourcePool $vm. ResourcePool)
}
# Save virtual machines
foreach ($info in $information)
{
$vmxpath = $info. Path
$resource_pool = $info. ResourcePool.Name
New-VM - ResourcePool (ResourcePool-Get-name $resource_pool) VMFilePath - $vmxpath - RunAsync-Verbose | Out-Null
}
Step 4
# Put the network cards
foreach ($info in $inventory)
{
foreach ($network_information in ($info.NetworkAdapter - split ":"))))
{
$virtual_machine = $info | %{$_. Name}
$network_adapter = ($network_information-split ",") [0]
$network_vlan = ($network_information-split ",") [1]
Get-VM-name $virtual_machine | Get-NetworkAdapter-name $network_adapter | Together-NetworkAdapter - NetworkName $network_vlan-Verbose-RunAsync-confirm: $false | Out-Null
}
}
# Start the virtual machines
foreach ($vm to $vm_list)
{
Start-VM - VM $vm. Name-RunAsync Verbose - confirm: $false | Out-Null}
}
Thanks in advance for any help.
Hi all
I made some changes to the script and it worked for me. We have added a host on the destination with all exchanges and storage mapped vCenter.
$vm_list = get-Cluster-name 'Site B - b | Get - VM | Name sort
$information = {foreach ($vm to $vm_list)
$network_adapter_information = get-NetworkAdapter - VM $vm
$vm | Select Name,PowerState,ResourcePool,@{N="Path; E= {$_. ExtensionData.Summary.Config.VmPathName}},@{N="NetworkAdapter '; E = {[string]: join (":", ($network_adapter_information |))} %{$_. {{(Nom + "," + _.NetworkName $}))}}, @{N = "MacAddress"; E = {[string]: join (",", ($network_adapter_information | % {$_.}))} MacAddress}))}}
}
# Unsubscribe virtual machines
Remove-VM - VM $vm_list-Verbose - confirm: $false
$cluster = get-Cluster "Site A - clustera.
{foreach ($vm to $information)
$ESXHost = get-Cluster $cluster | Get-VMHost | Select - 1 first
New-VM - VMFilePath $vm.path - VMHost $ESXHost - location $vm. Folder - ResourcePool (Get-Cluster $cluster |) Get-ResourcePool $vm. ResourcePool)
}
# Save virtual machines
foreach ($info in $information)
{
$vmxpath = $info. Path
$resource_pool = $info. ResourcePool
New-VM - ResourcePool (ResourcePool-Get-name "test1") VMFilePath - $vmxpath - RunAsync-Verbose | Out-Null
}
# Put the network cards
.
foreach ($info in $information)
{
foreach ($network_information in ($info.NetworkAdapter - split ":"))))
{
$virtual_machine = $info | %{$_. Name}
$network_adapter = ($network_information-split ",") [0]
$network_vlan = ($network_information-split ",") [1]
Get-VM-name $virtual_machine | Get-NetworkAdapter-name $network_adapter | Together-NetworkAdapter - NetworkName $network_vlan-Verbose - confirm: $false | Out-Null
}
}
# Start the virtual machines
foreach ($vm to $vm_list)
{
Start-VM - VM $vm. Name-RunAsync Verbose - confirm: $false | Out-Null
}
Hope this will help many of you.
-
Can write us "PowerCLI Script" to get the details of card RAID HP (Firmware & Driver)
For example: native ESX command below shows desired output for me.
But we needed equality PowerCLI ESX command below script
# cat/proc/driver/cciss/cciss0
cciss0: HP Smart Array P400i controller
Board ID: 0x3235103c
Firmware version: 7.22# cat/proc/driver/hpsa/hpsa0
hpsa0: HP Smart Array P410i controller
Board ID: 0x3245103c
Firmware version: 5,70
Driver version: HP HPSA driver (v 5.0.0 - 17vmw)
The extracted following PowerCLI you will get server and type of controller, firmware version and the hpsa/Smart Storage Array controllers driver version based of:
Get-VMhost | Sort | Select Name, Model,@{N='Controller Type'; E={(Get-VMHostHba -VMHost $_ | ? {$_.Model -imatch '.*(hpsa|smart).*'}).Model}},@{N='Controller Firmware'; E={($_.ExtensionData.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ? {$_.Name -like '*hpsa*firmware*'}).Name}},@{N='hpsa Driver Version'; E={($_.ExtensionData.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ? {$_.Name -like '*scsi-hpsa*'}).Name}} | Format-Table -Autosize
The sample output:
Name Model Controller Type Controller Firmware hpsa Driver Version---- ----- --------------- ------------------- -------------------esxihost1022.local ProLiant DL380 G6 Smart Array P410i HP Smart Array Controller HPSA1 Firmware 6.40 Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1023.local ProLiant DL380 G6 Smart Array P410i HP Smart Array Controller HPSA1 Firmware 6.40 Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1024.local ProLiant DL380 G6 Smart Array P410i HP Smart Array Controller HPSA1 Firmware 6.40 Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1033.local ProLiant DL360p Gen8 Smart Array P420i HP Smart Array Controller HPSA1 Firmware 5.42 Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1034.local ProLiant DL360p Gen8 Smart Array P420i HP Smart Array Controller HPSA1 Firmware 5.42 Hewlett-Packard scsi-hpsa 5.0.0.60-1OEM.500.0.0.472560 2014-05-15 15:32:23.000esxihost1041.local ProLiant DL380 G5 Smart Array P400 HP Smart Array Controller HPSA1 Firmware 7.24 VMware scsi-hpsa 5.0.0-17vmw.500.0.0.469512 2011-08-19 01:58:59.000esxihost1042.local ProLiant DL380 G5 Smart Array P400 HP Smart Array Controller HPSA1 Firmware 7.24 VMware scsi-hpsa 5.0.0-17vmw.500.0.0.469512 2011-08-19 01:58:59.000esxihost1160.local ProLiant BL460c Gen8 Smart Array P220i HP Smart Array Controller HPSA1 Firmware 5.22 Hewlett-Packard scsi-hpsa 5.0.0-40OEM.500.0.0.472560 2012-08-24 21:04:51.000esxihost1161.local ProLiant BL460c Gen8 Smart Array P220i HP Smart Array Controller HPSA1 Firmware 5.22 Hewlett-Packard scsi-hpsa 5.0.0-40OEM.500.0.0.472560 2012-08-24 21:04:51.000
-
Export and storage of CSV file details HBA device
Hi all
I need help in two PowerCLI scripting that can export information specific to the CSV files.
In the first report, I want to get out of HBA information in the fields "Name", "Identifier", "LUN" and "capabilities".
as seen in the screenshot just below.
In the second report, I would like to get storage information for the fields 'Identification', 'Device', and 'ability '.
as seen in the screenshot just below.
I am a newbie to Powershell and PowerCLI and have searched the threads and found a few scripts that provide similar information
but not exactly what I need. In my attempts to learn through "reverse engineering" everything I did was to hack the scripts and fail. =(
I use the following PowerCLI version.
----------------
VMware vSphere PowerCLI 4.1 build 332441 U1
---------------
Versions of the snap
---------------
VMWare vSphere PowerCLI 4.1 build 332441 U1Any help would be greatly appreciated.
OK, try this for the 1st report
&{foreach($esx in Get-VMHost){ foreach($hba in (Get-VMHostHba -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"})){ Get-ScsiLun -Hba $hba | Select @{N="VMHost";E={$esx.Name}}, @{N="HBA";E={$hba.Device}}, @{N="DisplayName";E={$_.ExtensionData.DisplayName}}, @{N="Identifier";E={$_.CanonicalName}}, @{N="LUN";E={(Select-String ":L(?
\d+)$" -InputObject $_.RuntimeName).Matches[0].Groups['lunID'].Value}}, @{N="Capacity";E={"{0:f2}" -f ($_.CapacityMB/1KB)}} } } } | Export-Csv C:\hba-report.csv -NoTypeInformation -UseCulture -
The package PowerCLI script in the Windows executable file / install
What are the options for packaging / embed PowerCLI script in Windows. EXE file? I would like for several departments to be able to run and collect information from the script without having direct access to the code. This would ensure that the code has been correctly run without modification.
I know that PowerCLI will be available on these systems, searching for the PowerCLI is not necessary.
I read that the Primal Script has this ability, but I want a solution that is free and easy to use, if possible.
If it is not an executable file, maybe even a file coded which makes it difficult for a layman to make changes.
Thanks in advance for the help!
I used a similar function of Johan Akerstrom in the past (since I don't have the community installed Extensions).
See his post Powershell script to generate an executable from a powershell script .
For this one, I know there is no problem with parameter passing.
Take this example script
param( [parameter(Mandatory = $true)][string[]]$server) [void][system.reflection.assembly]::LoadWithPartialName("System.Windows.Forms") Add-PSSnapin -Name VMware.VimAutomation.Core Connect-VIServer -Server $server[windows.forms.messagebox]::Show("Connected to " + $defaultViServer.Name) $VM = Get-VM[windows.forms.messagebox]::Show("I counted " + $VM.Count + " guests") Disconnect-VIServer -Confirm:$false
Note that the script uses Windows Forms to the output data.
You create the EXE file as follows. I recorded the example script under DoExeTest.ps1
PS C:\Scripts >.\DoExeTest.ps1 new-PSExecutable
Script source file: C:\Scripts\DoExeTest.ps1
Output executable: C:\Scripts\doexetest.exeAnd when you run this, it displays 2 message boxes, one with the name of the vCenter and the other with the number of guests, the script is located in the vCenter.
C:\Scripts>doexetest.exe 'Site '.
-
A Script to find and replace the layer names
Is there scripts to find and replace the names of layers?
There is an excellent script available for Photoshop that allows you not only to replace words in layer names, but also insert words as prefixes, Suffixes and sequential numbers.
The version of the illustrator of this script allows only sequential numbering: it does not offer search and replace words.
Ideally, it would be great if there were something that could find multiple and replaces in a go:
(for example
You have layers like this car, the dog, the bat
You enter: because (Option1), dog (Option2), Bat (Option3)
Your layers become then: option 1, option 2, Option3).
)
Big_SmiLe, which is a very good start! Step 1 of learning how to Script is indeed, by adjusting an existing simple script to make things more complicated. (And usually then "break something", which is also a necessary part of the process.)
You are right your comment, it comes to repetitive things. For one or two different articles that wouldn't be a problem, but in the longer lists you are soon lost.
As usual to work with lists of search - replace is to build a table:
var layernames = [ [ 'FHairBowlBoy *Hair', 'Hairboy1' ], [ 'FHairCurlyafroBoy *Hair', 'Hairboy2' ], [ 'FHairSpikyBoy *Hair', 'Hairboy3' ], ];
The general idea is to loop through all the names, check if the current layer name is "layernames [i] [0]" (the left column) and if so, rename it "layernames [i] [1]" (the right column). If you know how to write a loop in Javascript, then you can implement this immediately.
However...
A more advanced method to do this didn't need even loop on all layernames - instead you can immediately 'get' the correct name by layer! It's magic! Almost!
The trick is to use a Javascript object rather than a table. JavaScript objects are nothing special; "Layers" of Illustrator are an array of objects, and each object 'sex' has a 'name' property, which you can read and set the value. What I do here, is to create a new object, where the part 'name' is the name of the original layer and its value is the name of the new layer. All you need to check each layer is if there is a "object.originalLayerName" property and if so, assign its value to this layer name.
It looks a bit like the table above, except that (1) you use {.} instead of [..] to create an object and (2) you add pairs "name: value" instead of 'value' only (in fact, the 'name' of a value in a table is simply her number).
So here's what it looks like:
// JavaScript Document var doc = app.activeDocument; // name indexed object var layernames = { 'FHairBowlBoy *Hair':'Hairboy1', 'FHairCurlyafroBoy *Hair':'Hairboy2', 'FHairSpikyBoy *Hair':'Hairboy3' }; // loop through all layers for (var i = 0; i < doc.layers.length; i++) { //Set up Variable to access layer name var currentLayer = app.activeDocument.layers[i]; if (layernames[currentLayer.name]) { currentLayer.name = layernames[currentLayer.name]; } }
Enjoy!
-
What free programs I would like to extract comments and key words and put them into computer-based labels and legends Picasa? Is this possible with MSVB 2008 or 2010 Express? I'm not a real programmer, but I can hack a bit (in the old sense of the 1980s the word hack). I tried searching internet but no combination of the words comment, tag, keyword, and legend get something usable. Too common words, everything matches. BTW, I use XP, cannot afford to Windows Vista SE (that's my name for 7)
What I want to do is to add tags and comments to the photos that I am scanning. It is a long-term project to archive all the family of the peaks. Some dating back to 1900 photo of great great grandparents. The key here is long-term. I thought that the properties/summary/comments (and keywords) would be likely to be on board for many years (legacy stuff). Jac I can't find any program that uses or leans on them today! And I just saw a pic of the Win7 properties and guess what? No summary! Picassa is quite widely used but who knows. Nothing is stable for a long time. Can not even get to diskettes and CDs and cassettes now become more difficult to find. And DVDs are on the side too. How can I put the photos on the long term and accessible storage?
My plan is to use Picassa and .jpg. I'll put a copy of Picassa on every DVD that I use (in data mode). I'll do a mode DVD video slide show as a backup. The disks are pretty cheap even for me. I will not use double layer, but too unreliable. And I intend to check them every few years for readability. I have a few CD that can be read even with 12 years older data recovery programs.
So if anyone has any comments, suggestions or additions, let it go. I think that it is indeed an important subject, keeping old data accessible.
Hello
You can post the issue here for more information:
https://groups.Google.com/a/googleproductforums.com/Forum/#! categories/picasa/picasa-for-windows
-
Comments and highlights lost after formatting computer
Hello
So, I formatted my computer and re-installed the operating system and all of my comments and highlights that I have spend ages adding to PDF documents now seem to be lost. It is very unfortunate. In hindsight it was perhaps naïve to think that all these additions when connected to the individual pdf and thus would be preserved in the process. In any case, I would like to know how to avoid the same mistake in the future. IE: where are all these comments and highlights stored and can choose this storage location myself (i.e. who move to in my dropbox to save all the changes you made).
See you soon
Jakob
You cannot edit a file that is on Dropbox directly, though (unless it's on your local Dropbox folder). When you open it, it will download to a temporary file, you might have to manually download them later to update the version that is on the server.
To check if the file contains comments to open and then go to the comments on the right panel and check the list of numbers comments.
Make sure that the filter is set to show all reviews:
Is it is and it always shows the number of comments than zero, then they are simply not there.
-
Collection for the PowerCLI scripting requirements
Someone at - it a good model that helps you organize information, gathering process when you go to the management or to a customer to get for scripts and automation requirements that they want to do? Y at - it a Web page or a book that puts this kind of thing in a structured methodology or at least one practical how to guide?
For example, what kinds of questions should I go to make sure that I understand any of my script is supposed to do and help the management or the customer understand what THEY want to do, and get a consensus agreement on the functional requirements for my powerCLI script?
Your suggestions of entry, welcome masters strategies.
This question is not really unique for PowerCLI scripting, but all scripts/programs, to write (for yourself or for a customer |).
And of course, there are always the classic answer "it depends".
If it is a small task that you write yourself, the requirements are pretty obvious.
Most of the time, you have the requirements in your head, but it does not have to write in schematic form.
When you write for a customer, by definition be more formal (I guess).
An article I like, is the Introduction to gather our creative use cases and requirements published in the Code review.
Take a look.
-
County of vMotion and Storage vMotion over the last 24 hours
I am under the below a line to count the number of vMotion and Storage vMotion, which happened in the past 24 hours in the middle and it not give me the required result, but when I combine them in the script that I use to collect additional information, it's just returns 0 (zero) as the County.
Rely on Storage vMotion and vMotion
Get-VIEvent - MaxSamples ([int]: MaxValue)-start (Get-Date). AddDays(-1) |
Where {$_.} GetType(). {Name - eq "TaskEvent" - and $_.Info.DescriptionId - eq "VirtualMachine.relocate" - or $_.Info.DescriptionId - eq "StorageResourceManager.applyRecommendation"} |
Measure-object | Select-Object - ExpandProperty County
Get-VIEvent - MaxSamples ([int]: MaxValue)-start (Get-Date). AddDays(-1) |
Where {$_.} GetType(). {Name - eq "TaskEvent" - and $_.Info.DescriptionId - eq "VirtualMachine.migrate"} |
Measure-object | Select-Object - ExpandProperty County
Combined script
Get-Cluster |
{ForEach-Object
$Cluster = $_
$VMHost = $Cluster | Get-VMHost
$CpuUsageMhz = $VMHost | Measure-object-property CpuUsageMhz-sum | Select-Object - ExpandProperty sum
$CpuTotalMhz = $VMHost | Measure-object-property CpuTotalMhz-sum | Select-Object - ExpandProperty sum
$MemoryUsageGB = $VMHost | Measure-object-property MemoryUsageGB-sum | Select-Object - ExpandProperty sum
$MemoryTotalGB = $VMHost | Measure-object-property MemoryTotalGB-sum | Select-Object - ExpandProperty sum
$Cluster | Select-Object - property @{Name = "ClusterName"; Expression = {$_.} Name}},
@{Name = 'vSphere HA'; Expression = {$_.} HAEnabled}},
@{Name = 'Analysis HA-Host'; Expression = {$_.} ExtensionData.Configuration.DasConfig.HostMonitoring}},
@{Name = 'HA-Failover capacity'; Expression = {$_.} ExtensionData.Summary.CurrentFailoverLevel}},
@{Name = 'HA-Admission Control'; Expression = {$_.} HAAdmissionControlEnabled}},
@{Name = 'Configuration problem'; Expression = {[string]: join (",", ($_.))} ExtensionData.ConfigIssue | {{(Select-ExpandProperty FullFormattedMessage))}}.
@{Name = 'vSphere DRS'; Expression = {$_.} DrsEnabled}},
@{Name = "The DRS automation level"; Expression = {$_.} DrsAutomationLevel}},
@{Name = "Use of the CPU (Mhz)"; Expression is {$CpuUsageMhz}},
@{Name = "Cpu (Mhz) Total"; Expression is {$CpuTotalMhz}},
@{Name = 'Cpu use (%) » ; {Expression = {[Math]: Round(100*$CpuUsageMhz/$CpuTotalMhz)}},
@{Name = "use (GB) of memory"; Expression is {$MemoryUsageGB}},
@{Name = "Total (GB) of memory"; Expression is {$MemoryTotalGB}},
@{Name = 'use of memory (%) » ; {Expression = {[Math]: Round(100*$MemoryUsageGB/$MemoryTotalGB)}},
@{Name = 'VMS NB'; Expression = {$_ |} Get - VM | Measure-object | {{Select-Object - ExpandProperty County}},
@{Name = 'Virtual machines without VMXNET3 NB'; Expression = {$_ |} Get - VM | Get-NetworkAdapter | WHERE-object {$_.} Type - not "Vmxnet3"} | Measure-object | {{Select-Object - ExpandProperty County}},
@{Name = 'VMotions NB'; Expression = {$_ |} Get-VIEvent - MaxSamples ([int]: MaxValue)-start (Get-Date). AddDays(-1) | Where {$_.} GetType(). {Name - eq "TaskEvent" - and $_.Info.DescriptionId - eq "VirtualMachine.migrate"} | Measure-object | {{Select-Object - ExpandProperty County}},
@{Name = 'SvMotions NB'; Expression = {$_ |} Get-VIEvent - MaxSamples ([int]: MaxValue)-start (Get-Date). AddDays(-1) | Where {$_.} GetType(). {Name - eq "TaskEvent" - and $_.Info.DescriptionId - eq "VirtualMachine.relocate" - or $_.Info.DescriptionId - eq "StorageResourceManager.applyRecommendation"} | Measure-object | {{Select-Object - ExpandProperty County}}
} |
Export-Csv "C:\Script\Clusters.csv" - NoTypeInformation - UseCulture
Could you please someone check the script above and let me know if there is something wrong
Thank you!!
But wait a minute, you mean that the "Num vMotions" and "Num of SvMotions" properties have a value of 0?
This is normal, since you ask for events for the entity of the group, while you should do it for all the virtual machines in the cluster.
Try the attached version.
-
PowerCLI script to migrate virtual machines to the new vCenter environment
Hello world
in the next few weeks, we need about migrate 700 VMs (Windows/Linux) server to a new environment (new vCenter, new hosts, but VMs will remain on same data warehouses). VMs will be migrated not in one batch, but rather from time to time (which, however, can understand the need to migrate some 10s of virtual machines at the same time).
Cluster names and folder structure will be identical to the old and the new vCenters. As host in the new vCenter names differ from those in the old vCenter, thought to provide a table of 'translation', which tells the script to save a given VM on host B (new vCenter) when having been registered in order to host a (old vCenter) and so on.
I thought writing a PowerCLI script which, broadly speaking, can accomplish the following steps:
- Connect to vCenterOld and vCenterNew
- Correspondence table of host to read from a file (see step "register VM vCenterNew below)
Then, in a loop:
- Ask VM name
- Get the settings of the virtual machine: Datastore/path, network/Portgroup, HA restart priority, host, folder, note
- View the parameters and the VM name and request confirmation migrate the virtual machine
- Turn off VM (closed OS gracefully, but force power off if power status is still not equal 'off' after a time given)
- To unsubscribe from VM vCenterOld (removal of inventory)
- Registry of the VM to the data store vCenterNew (assumptions: same folder as vCenterOld, host names are different, but for each source in vCenterOld host a host of destination in vCenterNew for you join the virtual machine to can be provided, that is, CSV)
- The value of VM portgroup (same name as in vCenterOld)
- Set VM HA restart priority
- PowerON VM
- Wait / check the VM (for example, ping) connectivity / continue immediately if the virtual machine is accessible or after a certain time if the virtual machine is still inaccessible
- Confirm that the virtual machine has been migrated successfully, OR ask the user to check the connectivity of the virtual machine
Now to my questions:
- Is anyone know about an existing script that does something similar or contains parts that can be useful to compile a script like this?
- How can vCenter two connections at the same time been managed within a PowerCLI script - or doesn't work at all and a connect/disconnect to/from the two vCenters must be completed for each virtual computer?
Many thanks for any help.
The following seems to work for me
$vm = Get-VM -Name MyVM$nic = Get-NetworkAdapter -VM $vm $vdPG = $nic | select -ExpandProperty NetworkName Get-VDPortgroup -Name $vdPG
-
PowerCLI Script Create Role in vCenter
I'm looking for is a PowerCLI script to create a role in vCenter. I found this post, and I wonder if it can be adapted to my needs. What I need specifically is a script to create a role with all of the following privileges:
System.Anonymous
System.View
System.Read
Global.SetCustomField
Datastore.AllocateSpace
Network.Assign
VirtualMachine.Inventory.Create
VirtualMachine.Interact.PowerOn
VirtualMachine.Interact.DeviceConnection
VirtualMachine.Interact.SetCDMedia
VirtualMachine.Interact.GuestControl
VirtualMachine.Config.AddNewDisk
VirtualMachine.Config.CPUCount
VirtualMachine.Config.Memory
VirtualMachine.Config.AddRemoveDevice
VirtualMachine.Config.Resource
VirtualMachine.Config.DiskExtend
Resource.AssignVMToPool
VApp.Import
StoragePod.Config
It is possible with a PowerCLI script?You can get the file to root like this
Get-file-name of data centers
The rest of your script seems ok.
Maybe you are looking for
-
15ce156nr: usable physical memory (ram available)
my laptop has 6 GB of ram and boot manu specification, it shows only3.89 GB of ram is usable. .. Why?... .pls SNA...
-
Hello I just deploy the tomcat in windows server 2008 and to test whether it is installed correctly. When I opened the IE9 and type in http://localhost: 8080, he goes to the homepage of tomcat successfully. However, when I slap http://127.0.0.1:8080,
-
Windows 7 do not install updates
After I selected the Option 'Install updates and then close'. It seems to install without problem. The next time I log on, I icon in the system tray showing the same amount of updates are "ready for installation. They are the same updates each ti
-
Certificate of authenticity (COA)
Recently completed and automatic Windows Update on my computer. Apparently there was a mistake in the system and the corrupt my computer upgrade. Technology has to reinstall the operating system, but it cannot read the certificate of authenticity (
-
Quiz on progression to the next slide after an incorrect answer - Cp9
Hi just goes Cp8 Cp9, import an existing module created in Cp8. knows a mistake in action/behavior on a quiz question slide. When the wrong answer is sent, presents legend of failure (it's good, same as before); However, the 'click anywhere to contin