Need powershell scripts to collect information from vm disk

Hello

I need two scripts to collect information from vm drive,

1 script to collect information vm disk mode

Expected results:

The virtual computer name. Name of ESX. Cluster name | VMDK name | Device label. disksizeInGB | diskmode

Disc-> Just need the info as persistent or independent_persistent mode

2. script to collect info RDM of Vm

Expected results:

The virtual computer name. Name of ESX. Cluster name | DeviceName | File name | Compatibility mode | Size

The first script

Get-VM | %{
     $vm = $_
     $vm | Get-HardDisk | %{
          $_ | select @{N="VM";E={$vm.Name}},
               @{N="ESX";E={$vm.Host}},
               @{N="Cluster";E={(Get-VMHost $vm.Host | Get-Cluster).Name}},
               @{N="VMDK";E={$_.Filename}},
               @{N="Device Label";E={$_.Name}},
               @{N="disksizeInGB";E={"{0:N1}" -f ($_.CapacityKB/1MB)}},
               @{N="Diskmode";E={$_.Persistence}}
     }
} | ft -AutoSize -Force

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • Need a powershell script to gather information from ESX host

    Hello

    I need a powershell script to collect the below given information host ESX to the Virtual Center. My VC:2.5 of the environment, the ESX hosts: 2.5, 3, 3.5

    At present I have individual powershell scripts of a steamer to get these details. Would be more useful to have a single script. I tried VESI, but does not receive the report in the below in the format.

    | ESX host name Version | Number | construction | manufacturer Model | Processor type | Number of physical CPUS | Number of cores | VMotion service IP Console IP | | County HBA | Physical NETWORK interface cards count

    Thanks in advance!

    So I'm at my wits end here.

    It works for me and Robert also confirmed that it worked for him.

    Although I don't see why this would solve the problem, you could finally try an upgrade to PowerShell v2 RTM.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Help with the Powershell script to collect logs from all domain controllers

    I am writing a script to retrieve the last 5 days of application, security and log files from all domain controllers. The script runs, but fire the logs from the local server only. The variable $Computer has all of my DC so it's the fine mark. I guess it's a problem with my line ForEach-Object, but is not error. See the below script.

    $log = 'application '.
    $date = get-date-format MM-DD-YYYY
    $now = get-date
    $subtractDays = new-object System.TimeSpan 5,0,0,0,0
    $then = $Now.Subtract ($subtractDays)
    $Computers = get-ADDomainController-filter *.
    ForEach-Object - InputObject $Computers - process {Get-EventLog - LogName $log - after $then - before $now - EntryType error | select EventID, MachineName, Message, Source, TimeGenerated |} ConvertTo-html | {Out-file $env:TEMP\Applicationlog.htm}
    Invoke-Expression $env:TEMP\Applicationlog.htm

    Thank you

    Rich

    Hello

    To help with the repost the question script to the script Center Forum

    http://social.technet.Microsoft.com/forums/scriptcenter/en-us/home

  • Need a powershell script to collect info patch esx

    Hello

    IAM looking for a powershell script that collects the result of "motion esxupdate" for all versions of esx host 3.5 in the Virtual center 2.5 version and exports to CSV file.

    It should take input as virtual Center and collect all the information of ESX host, connect to esx hosts, run the esxupdate query and update of the CSV with results.

    I got the code base of other scripts. I've pasted below. He collects only results for esx server in view of the need to modify the code for the above requirements.

    -


    $servers = "server0″", server1″

    $account = "root".

    $password = "password".

    $servers | % {$a = plink - pw $password $account@$_ "esxupdate query"

    {$server = $_}

    -


    Thanks in advance!

    Have you tried running the script in the powershell console?

    May be a problem with the vesi script editor.

    Sent from my iPhone

    On 19 March 2010, at 21:14, Sureshadmin<>

  • Need a Script to pull data from use of resources based on the resource pool by.

    LucD I have created the script, but I wanted to add additional information such as total memory, CPU, Avg Total memory usage, below, the Avg CPU usage total storage.etc

    $report = @)

    {foreach ($cluster Get-cluster)

    foreach ($rp in Get-ResourcePool-location $cluster) {}

    foreach ($vm in (Get-VM-location the $rp)) {}

    $report += get-disk hard - VM $vm |

    Select @{N = "Cluster"; E = {$cluster. Name}},

    @{N = "ResourcePool"; E = {$rp. Name}},

    @{N = "VM"; E = {$vm. Name}},

    @{N = 'HD'; E={$_. Name}},

    @{N = "Datastore"; E={($_. Filename.Split(']') [0]). TrimStart('[')}},

    @{N = 'Filename'; E={($_. Filename.Split('_') [1]). "Split('/') [0]}},"

    @{N = 'Path VMDK'; E={$_. File name}}.

    @{N = "Format"; E={$_. StorageFormat}},

    @{N = ' Type'; E={$_. DiskType}},

    @{N = 'VM tools status'; E = {$vm. ExtensionData.Guest.ToolsStatus}},

    @{N = "CapacityGB"; E={$_. CapacityGB}}

    }

    $report | Export Csv C:\temp\report.csv - NoTypeInformation - UseCulture

    }

    }

    Something like below the lines wanted to add in my script above but could not understand how do. Need to add information resources as much as possible. Please help me on this.

    @{N='GHz CPU capacity';} E={[math]::Round($_. CpuTotalMhz / 1000 , 2 )}},

    @{N="GHz CPU used";} E={[math]::Round($_. CpuUsageMhz / 1000, 2 )}},

    @{N="CPU GHz free";} E={[math]::Round(($_. CpuTotalMhz - $_. CpuUsageMhz) / 1000 , 2 )}},

    @{N='Go memory capacity';} E={[math]::Round($_. MemoryTotalGB , 2 )}},

    @{N="Used memory GB";} E={[math]::Round($_. MemoryUsageGB , 2 )}},

    @{N="GB free memory";} E={[math]::Round(($_. MemoryTotalGB - $_. MemoryUsageGB) ,2 )}}



    The lines to add are displaying the results of a calculation on performance data, which are obtained through Get-Stat.

    In this script you better start from the script where you have taken these lines and then add the properties of the 1st script.

    In the objects returned by Get-Stat, you have access to the virtual machine through the property of the entity.

  • Script to collect information on an instance of rac oracle / Linux area normal conclusion?

    Hi all
    I have been instructed by the disaster recovery team to get a small quick script of race, to see what oracle instances are in a box, if it is raised, listener is running, etc.

    Normal, only one node instances so far, I've had success. I retrieve the data from the file/etc/oratab and parse try it with awk to get an ORACLE_SID and ORACLE_HOME and.

    This script is run as a user to the dba group, or the oracle so that each instance I try login through SQL * more than connect / as sysdba and not a request to collect information for instance that I echo the screen to determine that the instance is high and connectable.

    The problem I encountered, if there is an instance listed for a node in a RAC cluster... he can't see/etc/oratab entries are quite the same using dbca for RAC nodes as normal nodes.

    For example, say I have a RAC cluster that rac3 and rac1 rac2 nodes.

    From what I see... on the individual nodes, in the/etc/oratab entries only seem to put in for the cluster CCR, rather that say rac1. My script that tries to set the oracle sid and home and connect / as sysdba fails. If the entry has been made there as rac1, it should work, I think.

    Can anyone make any suggestions for me to use with this script, so that I can know which instance of node is running, if CARS is located on the computer... and automatically find and connect similar to how I am doing with the unique databases using/etc/oratab

    Is there a similar to/etc/oratab file that is used by the clusterware on the system?

    Thanks in advance,

    Cayenne

    Published by: cayenne on April 15, 2009 12:57

    Why don't doing by pmon... which I think does not work if she is down but up... you can just run something like:

    ps - ef | grep - v grep | grep pmon | cut '_' f d 3

    or... you could use the oracle_sid you get from oratab (dbname in this case... for example) and run the following:

    srvctl status database-d $sid_from_oratab | grep 'hostname ' | AWK '{print $2} '.

  • Why can't copy information from a disk to a CD - RW

    My computer: Windows Vista SP2 32-bit (Home Premium) network, Internet explore 8 No.

    I want to copy programs from a disk to a CD - RW, so it can be loaded on a computer without a floppy drive.

    I copied the info on my machine and the programs do not run. HOWEVER, I can't get the info on a CD. It will NOT format, so I erased a disc on which I got info. Tried to copy info and he entered in FORMAT mode and Windows could not complete the format. Help! thanx

    My computer: Windows Vista SP2 32-bit (Home Premium) network, Internet explore 8 No.

    I want to copy programs from a disk to a CD - RW, so it can be loaded on a computer without a floppy drive.

    I copied the info on my machine and the programs do not run. HOWEVER, I can't get the info on a CD. It will NOT format, so I erased a disc on which I got info. Tried to copy info and he entered in FORMAT mode and Windows could not complete the format. Help! thanx

    Use a CD - R.  No need to "format".

    While I appreciate your response. It is a stop-gap measure, but does not know why I can not format a disk. THANX

    Assuming you have done this before - with success - must understand that he has changed.
     
    I do not think that the diskette data have nothing to do with the question (especially since the data is copied from disk to the machine already.)
     
    Can still burn you - successfully - anything else?  As a file text you create on your desktop?
     
    You might consider third-party software - better in most cases anyway.

  • Script to collect data from several vcentres

    Hi all

    I have a few vCentres (5.5 and 5.1) I want to set up a scheduled task to collect some personal information and send me a csv file every 1st of the month.

    First, I test on 2 x vcentres only collection esxi hosts (the info that I need are different, but once I get the job of script I can change what I need).

    I have configure something like:

    $user = "domain\username".

    $pass = "user password"

    $vcentres = "IP1, IP2.

    ForEach ($vcentre to $vcentres)

    {

    $filedate = get-date - uformat ' %d-%m - Y % - hour %M ' %S

    $filename = "c:\tmp\reports\" + $vcentre + "_" + $filedate ".csv".

    Write-Host "connection to" $vcentre

    SE connect-viserver-Server $vcentre - user $user-password $pass

    Get-vmhost | Select name. Export-CSV $filename - NoType - UseCulture

    }

    Disconnect-viserver-Server *-confirm: $false

    I expected to receive 2 x csv files, one for each IP vcentre address, i.e., c:\tmp\IP1_date_time.csv and c:\tmp\IP2_date_time.csv

    Script runs the file but does not generate only 1 x csv with all inside esxi hosts.

    I think I need to install another variable to store the csv file when the first pass of the loop, then the second and finally to save to the specified location.

    Could anyone advice what I am doing wrong?

    Thanks to anticiaption.

    Try to make the VIServer disconnection in the foreach loop.

  • Need a Script to extract information for HA, DRS levels and admission control policy.

    Hello

    I'm looking for a Cli Script to get out information for HA, political admission control and the level of the DRS for each Cluster in the CSV format with the name of the Cluster

    (1) it must be HA information, they are handicapped his license, for each Cluster in vcenter.

    Admission control 2) enabled or disabled.

    (3) policy admission policy admission control type speciying control

    (4) DRS Automation level as manual, partially automated and fully automated.

    Need this info to keep track so we have several Cluster

    Thank you

    vmguy

    If you want to select only the groups whose name starts with Cluster, you can then change the command Get-Cluster in the first line of the script in:

    Get-Cluster-name Cluster *.

  • Collect information from snapshot without get-Snapshot

    We become counties instantaneous with the following code, is there a way to do it without get-snapshot? We try to reduce the number of snappets in the script because we are dealing with a large amount of virtual machines.

    Get - VM | % {
    $vmnet = $_. Get-NIC
    $vmds = $_. Get-Datastore
    $vmcls = $_. Get-Cluster

    $vms = "" | Select-Object SnapshotCount

    $vms. SnapshotCount = (Get-Snapshot - VM $_ |) Measure - Object). County

    }

    Something like that?

    Get - vm bswhatsup01 | get-view | snapshot select. Measure-Object | select count

    Thank you!

    If you only need County snapshot of th you can do

    Get-VM | Select Name,
    @{N="Nr of snapshots";E={$_.ExtensionData.LayoutEx.Snapshot.Count}}
    
  • CLI script can collect information RDM

    I was unable to find it in the documentation.  Y at - it a cmdlet or process that I can use to collect a list of virtual machines in a data center has attached RDM disks and info on these RDM disks, IE MONDAY, capacity, used (s)?

    This is the RDM disks.

    foreach($vm in (Get-Datacenter MyDC | Get-VM)){
        Get-HardDisk -VM $vm -DiskType "RawVirtual","RawPhysical" |
        select @{N="VM";E={$vm.Name}},ScsiCanonicalName,CapacityKb
    }
    

    Find the used disc space as far as I know is available on data warehouses.

    Or you could ask to leave in guest OS

  • Powershell scripts need to collect info ESX storage

    Hello

    I need three scripts to collect information from ESX storage as shown below

    1. information on the hardware-storage & gt; to collect information on the SCSI controller and HBA cards.

    ESX name | | SCSI controller HBA1 | HBA2

    Expected results

    ESX name | SCSI (model, Bios version, serial number, Raid config) | HBA1 (model, Firmware version, serial number, WWPN) | HBA2 (model, Firmware version, serial number, WWPN)

    Note: Need info on all controllers SCSI and HBA in the ESX box, so additional columns may be added as required.

    2. report on the use of storage - & gt; Usage report storage including local file system storage and SAN devices.

    ESX name | | File system Size | Opportunity | DISP | Use% | Mount point | Scopes

    Note: Need of all sizes in the UK. Extensions are applicable to data SAN storage and just the DiskID measure as vmhba1:1:1

    3 San disk information - & gt; To collect information on San Disk

    Disc ID | Lun ID | Size of the disk | Brand/model | Paths | Policy |     Active HBA WWPN

    Expected results

    vmhba1:1:1 | 0110 | 130 G | EMCxxxx | 4 | Fixed | xxxxxxxxxxxxxxx

    There was an error, you cannot delete items from a hash table by looping through the values.

    Try this one (it works for me).

    $nrMax = 10
    $taskHash = @{}
    
    Get-Cluster  | Get-VM | %{
      $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;
      $spec.cpuAllocation.Reservation = 0;
      $task = Get-View ($_.Extensiondata.ReconfigVM_Task($spec))
      $taskHash[$task.Info.Key] = $task
      while($taskHash.Count -eq $nrMax){
            $toBeRemoved = @()
            foreach($task in $taskHash.Values){
                $task.UpdateViewData()
                if("success","error" -contains $task.Info.State){
                    $toBeRemoved += $task.Info.Key
                }
            }
            $toBeRemoved | %{
                 $taskHash.Remove($_)
            }
      }
    }
    
  • How to collect information of a multi-node apps R12 environment.

    Hello experts,

    What are the ways, I can collect information from a multi-node environment.
    As if it is shared, etc. unified.

    Node 1:-database, Manager of competitor and Admin
    Node 2:-forms & web

    Application:-12.1.3 (R12)
    database :-11.2.0.3.0
    OS:-avalerps002dp SunOS 5.10 Generic_148888-05 sun4v sparc sun4v

    I'm new to the installation program.

    Kind regards
    Rahul

    Hello

    Please check old thread:

    APPL_TOP unified in R12 for the application tier of high availability?

    Re: How to find applications are shared or not

    Kind regards

    Hafiz

  • Plugin or script to collect books framemaker 10 or 11 with files, fonts, images etc. ?

    I'm looking for a plugin or script to collect books from framemaker 10 or 11 with files, fonts, images etc. ? ("Collect for output" I believe it was called...) I am aware of the plugin by Bruce Foster, but I think that this does not work for these new versions of Framemaker. Can anyone help?

    concerning

    Björn

    Hi again

    I also found this Googling autour:

    http://blogs.Adobe.com/TECHCOMM/2011/07/create-a-book-Packager-using-ExtendScript.html

    Thanks for the answers!

    concerning

    Björn

  • Need a script Powershell inventory VM

    Hello

    Need a script powershell to collect them below, has held information from the virtual Center.

    vmname | Name of ESX. Memory (GB) | County of vCPU | vNIC County | IP address (all) | VMDK (s) size (GB) | Total size (GB) vmdk | Name of the data store. The Tools version. to update the tools | actions | Reservations (MB) | Limit (MB) | County snapshot | Guest operating system

    VMDK (s) size (GB)-> need all size vmdk from the separated from the vm by ''. EX: for a virtual machine of 3 size vmdk 20,20, 10 GB each the output would be 2020 + 10

    The name of the data store-> name of the data store where the VMX.

    Update of the tools-> State of necessity as old or updates

    You will find the combined VM version of script 3 attached information. If you want only some of the fields, as in the VMX and VMDK script, you can use the Select-Object cmdlet to select only the fields. The next oneliner will use the script Get-information - v3.ps1 to generate the output of the VMX and VMDK script:

    ./Get-VMInformation-v3.ps1 | Select-Object -property VMname,VMXName,VMDKName,VmdkSizeGB,TotalVmdkSizeGB,DatastoreName
    

    Robert

Maybe you are looking for

  • Connect an iPod to an Android Ultra HD TV

    Is possible to connect an ipod touch 6G in os x 10.0.1 to Android from Sony TV. I would like to display or mirror of my photos on the big screen and maybe control my TV with iPod. So far I was able to get my ipod to connect using wi - fi or bluetooth

  • Firefox doesn't start and give the message "of setting werd geherintialiseerd.

    I tried everything first to solve the problem by resetting Firefox.When need to continue, I install version 23.It does not and the popup still appaers "of setting werd geherintialiseerd.I can't get on the internet with Firefox.On Internet Explorer, w

  • Project due to bad lack ejected the drive

    I just changed a project when, for no reason at all, the hard drive, that I was working on disconnected itself. I left the PCF, reconnected the hard drive and reopened FCP. The project now looks like a clip without content, and I don't know what happ

  • Problem with after downgrading fingerprint reader

    After downgrading from Vista to Xp business professional, I have some problems with my fingerprint reader. The error message is: 0xe7210005 user cannot be saved. Found no fingeprint reader. I have already installed the latest version of the driver so

  • Get 403: Forbidden of Google API - encoding problems in my POST?

    Hi all I have problems connecting to the Google API by MAIL by following the instructions on this page: http://code.Google.com/APIs/accounts/docs/AuthForInstalledApps.html#ClientLogin I've also posted on the forums of the Google API, but I'm starting