A virtual machine by CSV?
I use the metric graph widget. I don't see a way to get more data from a virtual computer on a simple CSV file. E.g., application (MHz) CPU for vm1 and application (MHz) CPU for vm2 in the same csv file. I can only download application (MHz) CPU to csv for a virtual machine at a time. Have two separate csv files, then combine them. What is a design limitation? Someone please tell me there is a better way...
Ok thank you. So when I create this supermetric, I select my group that I created in the Admin UI.
I don't select the "total application (MHz) under the"Metric"or"Attribute out? '"
I actually do a sumN() on the "total application (MHz)?
Should I add this SM to a package attribute?
When I create this supermetric, I can assign it to the group that I created in the editor of supermetric. However I still can not to appear on the widget "Metric Graph" for the group that was created in the Admin UI. I can only make it appear for a virtual machine at a time.
Tags: VMware
Similar Questions
-
Need a script to the list of all the virtual machines in CSV
I want to record a list of virtual machines from one host in a csv file so that I can add to their return with
New-VM - VMFilePath $VMXFile - $vmhost $ESXHost - $VMFolder location
I started with that, but am struggling with the name of the folder of the virtual machine (can be used in New-VM-map)
Get-VIServer-Server MyServer - protocol https-Force | out-null
$report = @)
Get - VM | Get-View | %{
$row = "" | Select Name, VmPathName, location
$row. Name = $_. Name
$row. VmPathName = $_. Config.Files.VmPathName
# $row. Location = $_. Folder # faced with this line
$report += $row
}
$report
# How to make this online, don't invite not not the user?
Disconnect-VIServer-Server MyServer - Force
Try this, it should give the blue files
New-VIProperty -Name 'BlueFolderPath' -ObjectType 'VirtualMachine' -Value { param($vm) function Get-ParentName { param($object) if($object.Folder) { $blue = Get-ParentName $object.Folder $name = $object.Folder.Name } elseif($object.Parent -and $object.Parent.GetType().Name -like "Folder*") { $blue = Get-ParentName $object.Parent $name = $object.Parent.Name } elseif($object.ParentFolder){ $blue = Get-ParentName $object.ParentFolder $name = $object.ParentFolder.Name } if("vm","Datacenters" -notcontains $name) { $blue + "/" + $name } else{ $blue } } (Get-ParentName $vm).Remove(0,1)} -Force | Out-Null Connect-VIServer -Server MyServer -Protocol https -Force | out-null $report = @()Get-VM | %{ $row = "" | select Name, VmPathName, Location $row.Name = $_.Name $row.VmPathName = $_.ExtensionData.Config.Files.VmPathName $row.Location = $_.BlueFolderPath $report += $row}$report Disconnect-VIServer -Server MyServer -Confirm:$false
-
Create the virtual machine by using the file PowerCLI and csv
I know there is a lot of info out there on this and I think I have a working script prety good. Much was borrowed from this thread, http://communities.vmware.com/thread/315193 many thanks to LucD.
My code is as follows:
# Deploy virtual machines from CSV file
# Much borrowed from http://communities.VMware.com/thread/315193?start=15 & tstart = 0
# CSV import file
Import-Csv "C:\guests.csv" - UseCulture | %{
# Gets the customization information to configure the static NETWORK card and assign the static IP address
Get-OSCustomizationSpec $_. Customization | Get-OSCustomizationNicMapping | `
Game-OSCustomizationNicMapping - UseStaticIP - IpAddress IpMode $_. ""IP address""
-Subnet mask $_. Subnet - DefaultGateway $_. Gateway - Dns $_. DNS
$vm = New-VM-Name $_. "" Server name "-model $_. Model-host $_. ' "The ESX host" '
-Datastore $_. Data store - OSCustomizationSpec $_. Customization"
-Confirm: $false - RunAsync
## .......
}He's going to cross and clone the virtual machine, and looks like he's running of the OSCustomizaitonSpec then it bombards. It cleans bad VM. Recent tasks shows "failed virtual machine clone that a specified parapeter was not correct." hostname ".
The problem is that I don't mean to set a hostname with the OSCustomixationSpec, I try only to IP address info.
I'm runningn PowerCLI 5.0.1 build 581491
My ESXi host is 5.0.0 build 914586
My vCenter Server is Ver 5.0.0 build 623373
I opened a new thread, because the age of the old thread. Not sure if this is the best way to do things.
A very simple and intuitive brake system :-)
## Deploy VMs from CSV File ## Much borrowed from http://communities.vmware.com/thread/315193?start=15&tstart=0 $maxJobs = 3 $currentJobs = 0 ## Imports CSV file Import-Csv "C:\temp\TestDeploy1" -UseCulture | %{ ## Gets Customization info to set NIC to Static and assign static IP address Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | ` ## Sets the Static IP info Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" ` -SubnetMask $_.Subnet -DefaultGateway $_.Gateway -Dns $_.DNS## Sets the name of the VMs OS $cust = Get-OSCustomizationSpec -Name Test Set-OSCustomizationSpec -OSCustomizationSpec $cust -NamingScheme Fixed -NamingPrefix $_.VMName## Creates the New VM from the template $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" ` -Datastore $_.Datastore -OSCustomizationSpec $_.Customization ` -Confirm:$false -RunAsync $currentJobs = Get-Job -State Running | Measure-Object | Select -ExpandProperty Count while($currentJobs -ge $maxJobs){ sleep 30 $currentJobs = Get-Job -State Running | Measure-Object | Select -ExpandProperty Count } ## ....... }
You can be more selective about the current jobs. For example, you can check if the name of the job shows that they are actually cloning jobs.
-
Hi gurrus and LucD
I'm looking for a Script that can list all virtual machines with type of NIC E1000 via the output of the CSV file.
The script should search for information in a multiple Vcenter servers and multiple clusters and list all the VMs name, status (two powers on or off) with type card NETWORK Type E1000 only no other.
Concerning
Nauman
Try like this
$report = @)
{foreach ($cluster Get-cluster)
foreach ($rp in Get-ResourcePool-location $cluster) {}
foreach ($vm in (Get-VM-location the $rp |)) Where {Get-NetworkAdapter - VM $_______ | where {$_.}} Type - eq "e1000"}})) {}
$report += $vm. Select @{N = "VM"; E={$_. Name}},
@{N = 'vCenter'; E={$_. Uid.Split('@') [1]. "Split(':') [0]}},"
@{N = "Cluster"; E = {$cluster. Name}},
@{N = "ResourcePool"; E = {$rp. Name}}
}
}
}
$report | Export Csv C:\temp\report.csv - NoTypeInformation - UseCulture
-
Hi all, I'm new here and it's been days I'm trying to find the right script to the list of virtual machines and related information on each cluster and get 1 csv for each individual cluster.
Here is my code:
Get-content C:\cl.txt | % {
$cl = $_
Get - VM | Select-Object @{N = 'Cluster'; {E = {Get-Cluster - VM $_}}, @{Expression = 'Host'; Label = "ESX host"}, @{Expression = "Name"; Label is "VM"},
@{Expression = "Numcpu"; Label = 'vCPU'}, @{Expression = "MemoryGB"; Label = "RAM (GB)"}, "
@{n = "Provisioned Volume"; e = {[math]: tour ($_.)}} (ProvisionedSpaceGB, 2)}}, @{n = "Use the Volume"; e = {[math]: tour ($_.)}} (UsedSpaceGB, 2)}},
@{N = "Ops ARE/s/write"; E = {[math]: tour ((Get-Stat $_-stat "datastore.numberWriteAveraged.average"-en temps réel |))} Select - expand the value | measure - average). Average, 1)}},
@{N = "Ops ARE/s/reading"; E = {[math]: tour ((Get-Stat $_-stat "datastore.numberReadAveraged.average"-en temps réel |))} Select - expand the value | measure - average). Average, 1)}} | Export-Csv - NoTypeInformation - UseCulture 'C:\vm_report_$cl.csv '.
}
Note: each csv is generated for each cluster
CL.txt lists the clusters , but all I get is several files with the same content, and they are not properly renamed
How can I do to generate 1 csv by cluster ?
For example, there are 3 groups A1, A2, A3 (in file cl.txt), we get 3 csv files generated individually A1.csv, A2.csv and A3.csv and related data in them:
A1.csv : A2.csv : A3.csv
Host cluster VM RAM (GB) Cluster ESX VM RAM (GB) Cluster Host ESX VM ESX host
A1 sx0001 su19001 4 sx0001adm 32 su1386adm su10670 A3 iu01990 A2
Sx0001 su23000 A1 2 A2 sx0001adm su12404 32 A3 sx1385adm su10034
Sx0002 su55000 sx0002pack sw12785 A1 2 A2 1 A3 su1384adm iu00025
Help with this script would you gladly.
Thank you
Joseph.
Judging by the timestamp, it seems that these files with spaces between the file name and file type, were made yesterday.
This might have been one of your previous tests?
Maybe do a series of tests of the script in an empty folder.
-
Hello
I entered the following two functions in my shell powercli
Two functions I have installed function {Get-VMEvents
< #.
. Logbook
Get events for an entity or query all events.
. Description
This function returns the events for the entities. It is very similar to
cmdlet Get-vievent. Please note that get-VMEvent can handle 1 vm at a time.
You can't send picture of vms in this version of the script.
. Example of
Get-VMEvents 0All-types "VmCreatedEvent", "VmDeployedEvent", "VmClonedEvent".
He will receive all events of type "VmCreatedEvent", "VmDeployedEvent"
'VmClonedEvent '.
. Example of
Get-VMEvents-name 'vm1' - type 'VmCreatedEvent '.
Will be out of the events of creation of virtual machine: "vm1. It's faster than the vms piping is of
result of Get - vm. There is no need to use get - vm to move names to get-vmevents.
Yet, it is OK when you do, it will be just a little more slow < span class = "wp-smiley wp-emoji wp-emoji-blink of eye" title = ';') > ;) </span >
. Example of
Get-VMEvents-name 'vm1' - category 'WARNING '.
Will be out all events for vm: 'vm1. It is is faster than the names of piping of
cmdlet Get - vm. Category will get-vmevent to search only the defined category
events.
. Example of
Get - vm "vm1 | Get-VMEvents-types "VmCreatedEvent", "VmMacAssignedEvent".
Shows events for vm1 which will be regarding the events of creation,.
and events when when / what mac address is assigned
. VM parameter
This setting is a unique string that represents the name of the vm. He expects this single vm name
There in the virtual Center. Now in the first version of the script, it will only load a case
where there is 1 instance of vm selected name. In the future it will load multiple as
Well.
. Types of parameters
If none is specified, it will return all the events. If specified will return
Only the events with selected types. For example: "VmCreatedEvent."
"VmDeployedEvent", "VmMacAssignedEvent" "VmClonedEvent", etc...
. Category of a parameter
Possible categories are: warning, info, error. Please use this setting if you
you want to filter events.
. Setting all the
If you need to set this parameter, so command queries all events
Center Virtual Server virtual machines.
. Notes
NAME: VMEvents
AUTHOR: Grzegorz Kulikowski
LASTEDIT: 09/11/2012
DOES NOT? #powercli @ irc.freenode.net
. Link
# >
(param
[Parameter (ValueFromPipeline = $true)]
[ValidatenotNullOrEmpty()]
$VM,
[String []] $variétés.
[string] $category,
[switch] $All
)
$si = get-view ServiceInstance
$em is get-view $si. Content.EventManager
$EventFilterSpec = new-Object VMware.Vim.EventFilterSpec
$EventFilterSpec.Type = $types
{if ($Category)}
$EventFilterSpec.Category = $category
}
If {($VM)
$EventFilterSpec.Entity = new-Object VMware.Vim.EventFilterSpecByEntity
switch ($VM) {}
{$_-is [VMware.Vim.VirtualMachine]} {$VMmoref = $vm.moref}
{$_-is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl]} {$VMmoref = $vm. ExtensionData.moref}
default {$vmmoref = (get - view - ViewType virtualmachine-filter @{'name' = $VM}) .moref}
}
$EventFilterSpec.Entity.Entity = $vmmoref
$em. QueryEvents ($EventFilterSpec)
}
If {($All)
$em. QueryEvents ($EventFilterSpec)
}
}
function get-vmcreationdate {}
< #.
. Logbook
Gets if possible virtual machine created.
. Description
This function will return the object with information about the creation time, method, of months,.
creator of particular virtual machine.
VMname: SomeVM12
Createduserid: 10/08/2012 11:48:18
CreatedMonth: August
CreationMethod: cloned
Creator: office\greg
This function displays NoEvent property in case when your VC do not
more information on these specific events, or your vm events no longer have
entries for the subject being created. If your VC data base has more tension date it is no longer possible
you find this event.
. Example of
Get-VMCreationdate - VMnames 'my_vm1', 'My_otherVM '.
This will return items that contain date information of creating virtual machines with names
myvm1 and myvm2
. Example of
Get-VM-location 'Cluster1 | Get-VMCreationdate
This will return items that contain information created for virtual machines that are
Located in Cluster1
. Example of
Notice-EEG - viewtype virtualmachine - SearchRoot (get-datacenter "mydc") user.user | Get-VMCreationDate
This will return items that contain information created for virtual machines that are
located in the data center "mydc" container If you use this feature in an existing loop where you
having the cmdlet get-view virtual machines, you can pass them via pipes or as a parameter VMnames.
. Example of
$report = get-cluster "cl-01' | Get-VMCreationdate
$report | Export-csv c:\myreport.csv
Stores all reported creationtimes object in the array $report variable and export the report to a csv file.
You can also filter the report before you write in the csv file using select
$report | Where-Object {$_.} {CreatedMonth - eq "October"} | Select VMName, CreatedMonth
So that you see only the vms that have been created in October.
. Example of
Get-vmcreationdate - VMnames "my_vm1", testvm55
WARNING: my_vm1 is not found, typo?
VMname: testvm55
Createduserid: 05/10/2012 14:24:03
CreatedMonth: October
CreationMethod: NewVM
Creator: home\greg
In case when you receive virtual machine that is not appropriate in the infrastructure of yor, a warning is displayed.
You can always store the full text of the report in the $report variable, but it includes all the information on
dates of creation of the missing vm. A warning always only for your information there is
probably a typing mistake in the name of the virtual machine.
. Parameter VMnames
This parameter must contain objects of virtual machine or strings representing vm
names. It is possible to supply this function wiith VM objects coming from get - vm or
get - view.
. Notes
NAME: Get-VMCreationdate
AUTHOR: Grzegorz Kulikowski
LASTEDIT: 27/11/2012
DOES NOT? #powercli @ irc.freenode.net
. Link
# >
(param
[Parameter (ValueFromPipeline = $true, mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Object []] $VMnames
)
{in process
{foreach ($vm to $VMnames)
$ReportedVM = "" | Select VMname Createduserid, CreatedMonth, CreationMethod, creator
If ($CollectedEvent = $vm |) Get - VMEvents - types "VmBeingDeployedEvent", "VmRegisteredEvent", "VmClonedEvent", "VmBeingCreatedEvent" - ErrorAction SilentlyContinue)
{
If ($CollectedEvent.GetType ().) IsArray) {$CollectedEvent = $CollectedEvent |?} {{$_-is [vmware.vim.VmRegisteredEvent]}}
$CollectedEventType = $CollectedEvent.gettype () .name
$CollectedEventMonth = "{0: MMMM}" $CollectedEvent.CreatedTime f
$CollectedEventCreationDate = $CollectedEvent.CreatedTime
$CollectedEventCreator = $CollectedEvent.Username
Switch ($CollectedEventType)
{
"VmClonedEvent" {$CreationMethod = "Cloned"}
"VmRegisteredEvent" {$CreationMethod = "RegisteredFromVMX"}
"VmBeingDeployedEvent" {$CreationMethod = "VmFromTemplate"}
"VmBeingCreatedEvent" {$CreationMethod = "NewVM"}
default value {$CreationMethod = 'Error'}
}
$ReportedVM.VMname = $CollectedEvent.vm.Name
$ReportedVM.CreatedTime = $CollectedEventCreationDate
$ReportedVM.CreatedMonth = $CollectedEventMonth
$ReportedVM.CreationMethod = $CreationMethod
$ReportedVM.Creator = $CollectedEventCreator
} else {}
If ($?) {
If ($vm - is [VMware.Vim.VirtualMachine]) {$ReportedVM.VMname = $vm.name} else {$ReportedVM.VMname = $vm.} ToString()}
$ReportedVM.CreatedTime = 'NoEvent.
$ReportedVM.CreatedMonth = 'NoEvent.
$ReportedVM.CreationMethod = 'NoEvent.
$ReportedVM.Creator = 'NoEvent.
} else {}
$ReportedVM = $null
Write-Warning "$VM is not found, typo?
}
}
$ReportedVM
}
}
}
Now, if I use the first command
Get - vm testvm
I get a response of
Name PowerState Num CPU MemoryGB
---- ---------- -------- --------
Receiving TestVM 4 4,000
But if I do
Get-vmcreationdate testvm
he responds with
WARNING: testvm is not found. misspelling?
I can't understand why he says this?
What will be the final objective to query the server vcenter set and export a CSV of the creation of each day VM - is their an easier way to do it?
I was intending to use
get - vm | Get-VMCreationDate | Export-Csv-path "d:\\reports\vmcreationinventory.csv ".
But at the present time, each unique virtual machine is indicating "is not found."
Attached is an example with a virtual machine called gbvls
Although you may be better communicate with the author of these functions, from what I can tell, it seems to indicate that none of the specified events were found for these virtual machines.
You can check if there are targeted with the cmdlet Get-VIEvent ordinary events.
If you can see events, there could be a problem with the Get-VMEvents function.
$vmName = 'testvm '.
$tgtEvents = "VmBeingDeployedEvent", "VmRegisteredEvent", "VmClonedEvent", "VmBeingCreatedEvent".
$vm = get-VM-name $vmName
Get-VIEvent-body $vm - MaxSamples ([int]: MaxValue) |
Where {$tgtEvents - contains $_.} GetType(). Name}
-
Not possible to export a list of virtual machines that are created in the past 7, 30, 120 and 180 days since an imported csv file containing the date of creation of virtual machine. My questions is the correct statement to the variable: $VmCreated7DaysAgo: $_CreatedOn "-lt" $CDate7.
# #SCRIPT_START
$file = "C:\Users\Admin\Documents\WindowsPowerShell\08-18-2014\VM-Repo.csv".
$Import = import-csv $file
$VMCreatedLast7RDayRepoFile = "C:\Users\Admin\Documents\WindowsPowerShell\08-18-2014\Last7Days.csv".
$start7 = (get-Date). AddMonths(-1)
$CDate7 = $start7. ToString('MM/dd/yyyy')
$VmCreated7DaysAgo = $Import | Select-object - property name, Powerstate, vCenter, VMHost, Cluster, file, Application, CreatedBy, CreatedOn, NumCpu, MemoryGB | Where-Object {$_.} CreatedOn - lt $CDate7} | Sort-Object CreatedOn
$TotalVmCreated7DaysAgo = $VmCreated7DaysAgo.count
$VmCreated7DaysAgo | Export-Csv-path $VMCreatedLast7RDayRepoFile - NoTypeInformation - UseCulture
Write-Host "$TotalVmCreated7DaysAgo VMs created in 7 days" - BackgroundColor Magenta
Invoke-Item $VMCreatedLast7RDayRepoFile
# #SCRIPT_END
You can use the New-Timespan cmdlet in the Where clause, it returns the time difference between 2 DateTime objects.
An example of this cmdley
New-TimeSpan-start (Get-Date). AddDays(-7)-end (Get-Date). Select days - ExpandProperty
In your case, you could do
Where {(New Timespan-démarrer ([DateTime] $_.))} CreatedOn) - end $start7). {7 days - gt}
But beware of negative numbers.
-
Orchestrator 5.1 REPORT-all the virtual machines in the data center and create a CSV file
Hello
What I basically want to do is create a report CSV of all virtual machines in the data center with various information (VMname, domain name FULL, IPaddress, status, data warehouses, tools etc...). The export list in the client feature is insufficient (especially for any KPI report).
Problem: (workflow is still under construction so real email send does not not and need to clean the code)
I am stuck at the part of the creation of a table that can be parsed correctly in the CSV file. 2 ways I've tried will produce a report of single object or combine all of the table into a single string (where I am now). I think the main problem I have is that I have to create a 2D within my service to push toward the final table that is written to the CSV format. Basically, I do not understand how to push my variables in a loop of a table.
Any help or assistance?
Thank you
B
BOOM!
Added some comments, removed the hardcoded in the csv temp file, deleted path the hardcoded port 25 for SMTP - mail settings should come from the configuration of the MAIL plug-in. And fixed / confirmed that the workflow now includes the attachment for e-mail and ends with success!
-
Deployment, customization and modification of virtual machines to a csv file
Hello
With lots of help from Eco91, I realized the script below. He deploys a series of virtual machines at the same time, waiting that they to initialize and make customization of the OS, and then changes the basis of networking within the OS and also changes in the Description of the network:
$esxName = 'esxqac4s01. MYDOMAIN.local ".
$template = "TEST_W2K8R2ENTSP1".
$datastore = "NFS_VM_Storage01".
$newVmList = @)
@{"Name" = 'TESTSVR1'; 'IP' = "10.244.186.136"; 'Mask' = "255.255.255.0". "Gateway" = "10.244.186.1"; "DNS" = @("10.244.37.25", "10.244.37.26"); "NetworkName" = "VLAN186_QA"; },
@{"Name" = 'TESTSRV2'; 'IP' = "10.244.186.137"; 'Mask' = "255.255.255.0". "Gateway" = "10.244.186.1"; "DNS" = @("10.244.37.25", "10.244.37.26"); "NetworkName" = "VLAN186_QA"; },
@{"Name" = 'TESTSRV3'; 'IP' = "10.244.186.138"; 'Mask' = "255.255.255.0". "Gateway" = "10.244.186.1"; "DNS" = @("10.244.37.25", "10.244.37.26"); "NetworkName" = "VLAN186_QA"; },
@{"Name" = 'TESTSRV4'; 'IP' = "10.244.186.139"; 'Mask' = "255.255.255.0". "Gateway" = "10.244.186.1"; "DNS" = @("10.244.37.25", "10.244.37.26"); "NetworkName" = "VLAN186_QA"; }
)
$custSpec = "TEST_W2K8R2ENTSP1".
$location = "_Tobedeleted".
$taskTab = @ {}
SE connect-VIServer-Server vvcqa01yyz. MYDOMAIN.local - user 'MYDOMAIN\MYACCOUNT' - password MYPASSWORD
# Create all virtual machines specified in $newVmList
{foreach ($VM to $newVmList)
$taskTab [(nouvelle-VM-nommez $VM.)] Name - VMHost (Get-VMHost-name $esxName) - model $template - $datastore - OSCustomizationSpec $custSpec Datastore - location $location - RunAsync). ID] = $VM. Name
}# Start each virtual machine that is over
$runningTasks = $taskTab.Count
While ($runningTasks - gt 0) {}
Get-job | % {
If ($taskTab.ContainsKey ($_.)) (ID) - and $_. State - eq 'Success') {}
Get - VM $taskTab [$_] ID] | Start-VM
$taskTab.Remove ($_.) ID)
$runningTasks-
}
else if ($taskTab.ContainsKey ($_.)) (ID) - and $_. State - eq "Error") {}
$taskTab.Remove ($_.) ID)
$runningTasks-
}
}
Start-Sleep - seconds 5
}
# START HERE
# Wait for customization of the OS
Start-Sleep - seconds 300
# Customize network
{foreach ($VM to $newVmList)
Get-NetworkAdapter - VM $VM. Name | Together-NetworkAdapter NetworkName - $VM.NetworkName - confirm: $false
Get-VM-name $VM. Name | 'Administrator' Get-VMGuestNetworkInterface - Guestuser - GuestPassword ' R! m2009 |? {$_.name - eq "Connect to network Local 4"} | Game-VMGuestNetworkInterface - Guestuser 'Administrator' - GuestPassword ' R! m2009"- IPPolicy - static IP $VM. $VM.Netmask - IP-Gateway $VM subnet mask. Gateway - DNS $VM. DNS
}I would now like to replace the $VMlist variable and put rather information eVM th to a .csv file. Any suggestions?
Hello
assuming this is your csv file
"name","ip","netmask","gateway","dns","networkName" "TESTSRV1","10.244.186.136","255.255.255.0","10.244.186.1","10.244.37.25;10.244.37.26","VLAN186_QA"
you have a problem. Impossible to save all the tables in a csv file and do powershell natively recognize them.
Instead, use a delimiter custom (not the same csv uses!) and split - to import - in a table. Look at the semicolon between two dns servers.
$newVmList = import-Csv test.csv | Select-Object - property 'name', 'ip', 'mask', 'bridge', @{Name = "dns"; {Expression = {$_ .dns-split ';'}}, "networkName".
The object resulting looks like this
name : TESTSRV1 ip : 10.244.186.136 netmask : 255.255.255.0 gateway : 10.244.186.1 dns : {10.244.37.25, 10.244.37.26} <-- Array networkName: VLAN186_QA
Concerning
Emanuel
-
Create the list of virtual machines to exclude the script through .csv file?
Hello
I have a script that runs all day off hours to check my VMs respect some things, like having the option to 'VM tools upgrade policy' checked. The script will export a list of virtual machines that DO NOT have this option enabled and then later to fix the problem. Now, for some specific VMS, I don't want to have the option active and want to exclude them from this review. I try to add a list of these virtual machines I want to exclude from my check script of VMTools_UpgradePolicy via a .csv file containing their names. Here's what I have:
##############################################
#VMTools update during the feeding cycle - report
##############################################
function Report_VMTools_UpgradePolicy {}
$list = import-Csv "C:\VMware\PowerCLI\Scripts\EXCLUDE LIST\EXCLUDE_vmtools_upgradepolicy.csv".
foreach ($entry in $list) {$exclude = Get-VM-name $entry. Name}
$vms = get - Vm | where {$_.} Name - not $exclude - and (Get-View-Id $_.) {ID). Config.Tools.ToolsUpgradePolicy - eq 'manual'} | Select name
$vms | Export-Csv "C:\VMware\PowerCLI\Scripts\REPORTS\vmtools_upgradepolicy.csv" - NoTypeInformation
}The content of the EXCLUDE_vmtools_upgradepolicy.csv is as follows:
'Name '.
"VM1.
"VM2."VM3.
I try to get all the virtual machines in my environment who have the ToolsUpgradePolicy - eq 'manual' (unchecked), AND which do not match any of the names on my list of exclusions (VM1, VM2, VM3). My script so far will do what I want, except that only the last entry in my list of exclusions will take into account. VM1 and VM2 will still be reported as VMs that need to be addressed.
I'm not sure that I am taking the right approach with this, I will continue to seek a solution for what I want, but any help would be appreciated! I prefer to make my list of exclusion to a separate file, for example "EXCLUDE_vmtools_upgradepolicy.csv", because I want that other administrators to be able to just open this .csv file and add virtual machines to this list without having to touch my scripts.
Thank you!
Vince
Hi Vince,.
It is like that I think because of your statement:
foreach ($entry in $list) {$exclude = Get-VM-name $entry. Name} -> it
$vms = get - Vm | where {$_.} Name - not $exclude - and (Get-View-Id $_.) {ID). Config.Tools.ToolsUpgradePolicy - eq 'manual'} | Select name
$vms | Export-Csv "C:\VMware\PowerCLI\Scripts\REPORTS\vmtools_upgradepolicy.csv" - NoTypeInformation
}$exclude is a variable that contains only 1 entry., that's why you see only the last element inside. It will not be an array.
foreach ($entry in $list) {[string []]+ $exclude = Get-VM-name $entry.} Name}
This will fill $exclude table with entries of string that will contain the names of virtual machine.
And when you will be comparing. I think you should use
where {$exclude - notcontains $_.} Name - and... the rest
Kind regards
Greg
-
I have problems to find a way to get a list of virtual machines on an ESX host specific and then he dumped to a .csv in the following format
I use the get-vmhost esxhostname | Get - vm
but everyhting else after, it is where I am lost... I think the closest I had been posting the output with a goofy header and format 'vm1, vm2, vm3 "...
name
computer 1 name
computer 2 name
name of the machine 3
to use for later use. Any help would be appreciated.
You must use the Select-Object cmdlet to specify more precisely the properties you want.
The Export-Csv doesn't know how to manage the virtual computer object.
Something like that
Get-vmhost esxhostname | Get - vm | Select name. Export Csv.\report.csv - NoTypeInformation - UseCulture
-
Generate the CSV file to the virtual machine by using get-stat statistics
Hi all
I put my VC for taking samples every 5 minutes for 3 days.
I would create a PowerCLI script that I can then run on an ad hoc basis to connect to my VC and to get the details for ALL of the virtual machines that are managed by this CR and fill in a CSV (c:\foo.csv):
Name of the virtual machine
The ESX VM host is currently sitting
total number of virtual processors assigned to VM
total memory allocated to the VM
memory active average used by the virtual machine in the 3 days using samples of 5 minutes
average mhz CPU used by VM spent 3 days using samples of 5 minutes
I have attached a sample file XLS of CSV output should look like.
If anyone can give me a code to achieve or get on well on my way, I would appreciate it a lot.
Kind regards
Alex
OK, so what you want is something like this then?
Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Select Name, Host, NumCpu, MemoryMB, @{N="Cpu.UsageMhz.Average";E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddHours(-72) -IntervalMins 5 -MaxSamples (12) | Measure-Object Value -Average).Average),2)}}, @{N="Mem.Usage.Average";E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddHours(-72) -IntervalMins 5 -MaxSamples (12) | Measure-Object Value -Average).Average),2)}}
I think that the issue that you have with the missing stat might be to do with your logging levels in VC, if these are not set correctly it will not save these stats for this period of time.
What do you get if you do a simple:
get-vm "SingleVM" | Get-Stat -Stat cpu.usagemhz.average
If you found this information useful, please consider the allocation of points for correct or helpful.
Alan Renouf
-
How to import the list of virtual machines to complete a table in a workflow
When you run the followingworkflow/library/vCenter/batch/run a workflow on a selection of objects
How import you a list of virtual machines to complete the table of virtual machines?
At this moment we are manually by selecting the virtual machines and adding them to the table individually which is very tedious. We would simply import a list.
There is a certain ways that you can do what you're trying to do, but from your description, it looks like a wrapper will work best. I enclose a simple workflow that loads the table from a csv file. There is no error checking going on, but it should help you get started and you can expand on it from there.
-
Sharing the drive between several virtual machines
Hi all
We have a configuration with a SAN (Dell Compellent) and use vSphere 6 to host a number of Windows servers. We now have a giant machine of Windows with a large number of small files for a particular application.
Now, we would like to create a cluster with a LoadBalancer in front of him, so that we can handle more load. To do this, we want to create a disk that is shared between 2 (or more) of windows machines.
One of the problems is that NTFS is not a supported clustered file system. So, I did a lot of research on Google to see what my options are. In my opinion, they are the following:
1. set up a Cluster Shared Volume (CSV) Microsoft (use SMB if I read the documentation)
2. the user Windows shares on a separate file server
3. the user NFS (depreacted under Windows)
4. switch to Linux and use NFS
The problem I have, is that they use all the network traffic. For example, option 2 is ridiculous slow. NFS under Linux is also a way slower than the local drive (managed by VMWare iSCSI) disk access and NFS on windows does not appear to be
support very well.
I know that there are aware filesystems, clustered as VMFS etc. Is there a way to access it directly from my Windows VM or are there devices SAN which is directly accessible from the virtual Windows machine?
Or maybe there are other solutions to set up a shared drive?
I know that there are aware filesystems, clustered as VMFS etc. Is there a way to access it directly from my Windows VM or are there devices SAN which is directly accessible from the virtual Windows machine?
VMFS is a really clustered file system and allow access of multiple virtual machine the same amount of storage (data store) which is different from that to create a virtual disk (hard) and present to multiple virtual machines. You can do this, BUT the guest virtual machine should take care of several accesses to the hard, for Windows, you must turn on the feature... without this clustering with failover data may be corrupted.
I think the best and supported solution for you is to create another cluster with Failover Cluster functionality and create a resource sharing files with files that will access your NLB nodes.
-
Migration of virtual machines to vSphere 4.1 to vSphere 6.0
As the title eludes to, we are standing up a new physics 6.0 Server vCenter Server and need to migrate virtual machines of 4.1 6.0 guest hosts. I'd love to take the time to create a script that does the following; However, before heading down this path, I wanted to do a ping of the group to see if someone has done something like this before or have pointers to scripts that perform some of these actions already. Some background and concept:
- Running 4.1.
- A new physical Center of vCenter 6.0 will be deployed side-by-side with 4.1.
- The existing configuration of vSphere HA allows for 1-2 guests down without impact to the virtual machines.
- The two environment and will be Cisco N1KV, SAN access shared for the same data storages.
- A new vCenter will be lifted.
- A single host is identified and VMs evacuated to the remaining hosts.
- This host will be in maintenance mode, removed from the cluster and close.
- A clean install of ESXi 6 will be done and set up spec.
- N1KV will be deployed.
To digress on the details at the moment... Now markets PowerCLI desired. This idea is ad hoc and on the fly, so as I write this.
- identify all the virtual machines associated with a specific data store - will need to work with the local client to schedule downtime for virtual machines
- Stop the virtual machine
- Remove the VM of the vCenter 4.1 inventory
- to connect to vCenter 6.0
- Add the virtual machine to the vCenter 6.0 inventory (and once we have passed the first host in the new cluster, automatically place the virtual machine by using the DRS)
- Reconfigure the vmnic with the new Cisco 1000V dvs (will be the same name on both sides, but has a different ID)
- pull in the keys and the values to a CSV and advancedsetting set to harden
- Turn on the virtual machine
- Perhaps a test of ping for the NETWORK card to check connectivity
The order in which the steps are performed can be switched around, as long as the desired end result is the same: migration effectively virtual machines between two disparate solutions with single medium sharing as a data store. In which I realize will always be VMFS3. New data stores VMFS-5 is another task for another time.
Thank you for your time, suggestions, links, etc...
@LucD - hi.
These steps are quite possible with PowerCLI.
See the script after skeleton, he probably needs some adjustments to fit your environment and requirements
$dsName = "xyz".
$vm = get - VM - $dsName data store
Stop-VMGuest - VM $vm - confirm: $false
Remove-VM - $vm VM - confirm: $false
Disconnect-VIServer-Server vc41 - confirm: $false
$vc6 = Connect-VIServer-Server vc6
$newVM = $vm | New-VM - DiskPath $_. ExtensionData.Config.Files.VmPathName - confirm: $false
# Suppose a CSV file with
# Key, value
# key1, value1
# key2, value2
$advSettings = import-Csv - UseCulture advSettings.csv
{foreach ($obj in $newVM)
$advSettings | %{
Get-AdvancedSetting - $obj entity - name $_. Key |
Game-AdvancedSetting - value of $_. Value - confirm: $false
}
}
Start-VM - $newVM VM - confirm: $false
$newVM |
Select Name,
@{N = "Available"; E = {Test-Connection - ComputerName $_.} Guest.HostName - County 1 - Quiet}}
Maybe you are looking for
-
Transfer files from iPhone to android Bluetooth
All the apps to transfer files from iPhone to android Bluetooth?
-
Disable/remove password Public iPad without MDM
I bought six air iPad (running iOS 9.2.1) for "iPad reference Bar." school library these iPads are in a public space in a kiosk of the enclosure. While I placed many restrictions on these iPads, some students keep by allowing an access code. Then the
-
Satellite A105-S361 without recovery DVDs
Hi all I recently bought a Satellite A105-S361 and now I have discovered that I do not have the recovery DVD and I don't have the possibility to recreate the DVD recovery my HD was formatted once. How can I solve this problem? Thanks in advance, Clau
-
LASERJET 1300: fatal error in laserjet 1300
I bought a 'new' in the Laserjet 1300 to a thrift store box when I turn it on it shows "ready" light, works, all gears seem to be turning, doing this for about 1 minute, then stops and shows fatal error, turn off and turn back on, same thing, any hel
-
mg5400 does not scan. do not print remotely
I have a mg5400 that I really like and served me no problem until recently. It is now more communicates wireless. It must be hard wired to accept a print command. says the printer is offline, even if it is running. takes immediately and prints as