PowerCli DataStore Audit?

Hello

I was wondering if someone could help me with a script.  I need to perform an audit of our data with capacity warehouses, put into service and available.  I found a code snippet that returns the information I need, but is there a way to indicate these cluster data stores that are assigned to?

Here is the code I use.

$report
= @() get-datastore

| % { 
$info = "" | select DataCenter, Name, Capacity, Provisioned, Available 
$info.Datacenter = $_.Datacenter 
$info.Name = $_.Name 
$info.Capacity = [math]::Round($_.capacityMB/1024,2) 
$info.Provisioned = [math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2) 
$info.Available = [math]::Round($info.Capacity - $info.Provisioned,2) 
$report += $info }
#$report | sort Available | format-table –auto









Ideally, I would have a spreadsheet with a spreadsheet separate for each Cluster, but having a single sheet with all data warehouses and their grouping would be nice as well.

THX

Try something like this

$report = @()

foreach($cluster in Get-Cluster){
    Get-VMHost -Location $cluster | Get-Datastore | %{
        $info = "" | select DataCenter, Cluster, Name, Capacity, Provisioned, Available
        $info.Datacenter = $_.Datacenter
        $info.Cluster = $cluster.Name
        $info.Name = $_.Name
        $info.Capacity = [math]::Round($_.capacityMB/1024,2)
        $info.Provisioned = [math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)
        $info.Available = [math]::Round($info.Capacity - $info.Provisioned,2)
        $report += $info    }
}

$report | Export-Csv "C:\cluster-ds.csv" -NoTypeInformation -UseCulture

If you have a cluster with worksheet in a spreadsheet, you can use the function of my post called beyond Export-Csv: export Xls

The script would be slightly modified.

 foreach($cluster in Get-Cluster){
    $report = @()
    Get-VMHost -Location $cluster | Get-Datastore | %{
        $info = "" | select DataCenter, Cluster, Name, Capacity, Provisioned, Available
        $info.Datacenter = $_.Datacenter
        $info.Cluster = $cluster.Name
        $info.Name = $_.Name
        $info.Capacity = [math]::Round($_.capacityMB/1024,2)
        $info.Provisioned = [math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)
        $info.Available = [math]::Round($info.Capacity - $info.Provisioned,2)
        $report += $info    }
    $report | Export-Xls -Path C:\ds-cluster.xls -WorksheetName $cluster.Name -SheetPosition "end"}

Tags: VMware

Similar Questions

  • PowerCLI datastore report

    Hello

    could you please provide me with the script to report data format below store

    NameCapacity GBGB provisioned%(Provisined/capacity) capacityUse GBGB free% Free
    datastore11290.949218750.740.9492187512899

    You can redirect the result of the Select-Object cmdlet to the Export-Csv cmdlet.

    Like this

    Get-Datastore.

    Select Name, CapacityGB, FreeSpaceGB,

    @{N = "% free"; E = {'{0:p1}' f ($_.)} FreeSpaceGB / $_. CapacityGB)}}.

    @{N = "ProvisionedGB"; E = {'{0:N1}' f ($_.)} CapacityGB - $_. FreeSpaceGB)}}.

    @{N = 'Provisioned %'; E = {'{0:p1}' f (($_.))} CapacityGB - $_. FreeSpaceGB) / $_. CapacityGB)}}.

    @{N = "use GB"; E = {'{0:N1}' f ($_.)} CapacityGB - $_. FreeSpaceGB + $_. ExtensionData.Summary.Uncommitted/1GB)}}.

    @{N = 'in use %";} E = {'{0:p1}' f (($_.))} CapacityGB - $_. FreeSpaceGB + $_. ExtensionData.Summary.Uncommitted/1GB)/$_. CapacityGB)}} |

    Export-Csv "D:\Users\rpotluri\datastore.csv" - NoTypeInformation

  • PowerCli for audit information

    Hi folks can anyone help with this, I need to get the information below are virtual environment (each esxi and esx host) and was wondering if someone has a script to complete?

    Vpshere product name

    Version 4.1 etc.

    Enterprise edition etc.

    Name of the computer ESX1 etc.

    Number of cores

    Number of physical processes

    I can get the name of carrots and physics by the GET-vmhost | selection version, name, Numcpu etc, but I'm not sure there is a better way to get it?

    Also Vcentre info - information about the license if anyone can help with this.

    Thanks to all who responded.

    Hello

    regarding the licensing stuff feel free to throw a look my solution

    http://psvmware.WordPress.com/2012/08/13/get-licensereport-to-obtain-informations-regarding-licenses-within-virtual-Center/

    And for the properties that you are looking for here, you were doing ok

    Get-vmhost | {select version,name,@{n='total CPU; e = {$_.numcpu}}, @{n = 'number of sockets'; e = {$_.extensiondata.hardware.cpuinfo.numcpupackages}}

    for guests, it will choose its version, the host name, the number of cpu, the number of sockets

    The rest you will earn on top of link

    Kind regards

    Greg

  • List NETWORK adapter physical autonegotiation setting

    Hello all I hope someone can help me here.  I'm trying to find out if there is a way using powercli for audit/list all the parameters of NETWORK card physical hosts.  Specifically, I need to know if the NETWORK card is hard codes at a particular speed or if it is set to auto negotiate.  And also its current speed / duplex or if it is broken.

    I have reviewed the results of get-display of a host, but were not able to determine exactly what says the Iftar NIC physical real parameters - v it runs to the.

    Thanks for the help.

    Hey Joe,

    I should have been reading yesterday.

    You are right about the auto-negotiation. You can find in the documentation of PhysicalNicSpec . It says on the LinkSpeed property:

    The link speed and duplex mode this physical network adapter is currently configured to use. If this property is not set, the physical network adapter autonegotiates its settings.

    According to PhysicalNic documentation if the LinkSpeed property in this object is not set, then the link is down.

    This brings me to the next new version of my script:

    Get-VMHostNetworkAdapter |
    Where-Object {$_.GetType().Name -eq "PhysicalNicImpl"} |
    Select-Object -Property VMHost,Name,BitRatePerSec,FullDuplex,
      @{Name="AutoNegotiate";Expression={
        if ($_.ExtensionData.Spec.LinkSpeed)
          {$false} else {$true}
      }},
      @{Name="LinkState";Expression={
        if ($_.ExtensionData.LinkSpeed)
         {"Up"} else {"Down"}
      }}
    
  • PowerCLI script for VMFS datastore list with ID NAA and latency?

    Hi all

    Can anyone here please share a script, or help me to change the PowerCLI to display the store name of VMFS data, capacity and NAA.ID and latency in the past 24 hours?

    So far I can only use the WHowe script below:

    $esxName = "PRODESXi10".

    SE PRODVCENTER01-connect-VIServer-Server "VM".

    New-VIProperty-name lunDatastoreName - ObjectType ScsiLun-Value {}

    Param ($LUN)

    $ds = $lun. VMHost.ExtensionData.Datastore | % {Get-view $_} | `

    where {$_.} Summary.Type - eq "VMFS" - and

    (_.Info.Vmfs.Extent $ |) where {$_.} DiskName - eq $lun. CanonicalName})}

    {if ($DS)}

    $ds. Name

    }

    } - Force | Out-Null

    Get-VMHost-name $esxName | Get-ScsiLun | Select CanonicalName, CapacityMB, lunDatastoreName

    Thanks in advance,

    But you easily add a timestamp.

    Get-Datastore.

    Select Name,

    @{N = "DateTime"; E = {Get-DateTime}},

    @{N = "CanonicalName"; E = {$_.ExtensionData.Info.Vmfs.Extent [0].} DiskName}},

    @{N = 'Latency'; E = {}

    $esx = @(get-View-Id $_.) ExtensionData.Host.Key | Get - VIObjectByVIView)

    $instance = $_.ExtensionData.Info.Vmfs.Uuid

    $stat = 'datastore.totalReadLatency.average ','datastore.totalWriteLatency.average '.

    $stats = get-Stat-entity $esx - Stat $stat - Realtime - MaxSamples 1 - Instance $instance

    ($stats |) Measure-object-property - average value. Select - ExpandProperty average) /($esx.) Count * 2)

    }}

  • How to calculate the IOPS datastore / s and latency via Powercli?

    Hi all!

    I want to calculate the IOPS / s (RO/RW) and the latency of the data via Powercli store, but I cant' find this metric in Vcenter (in the data store tab) and see no metric for data via the cmdlet Get-Stat store.

    How can we measure IOPS / s and latency of data store?  For example I know veeam monitor this information - http://cdn.swcdn.net/creative/v16.8/images/screenshots/products/VM/Lg/EN/VMan60-Orion-Datastore-Top_Lg_960x540.jpg

    I know, I can get this VM or vmhost metric, but I need information on the data store.

    How to measure for IOPS / s and latency of data properly store?

    Thanks in advance!

    These measures are collected on ESXi nodes, entity would need to have the ESXi nodes where these data warehouses are connected.

    You can use the Instance property to filter.

    Under the PerformanceManager , you see all the measures for each indicator it indicates under which entity this metric is collected.

    And Yes, the cmdlet Get-inventory returns no data warehouses.

    There is a little, aggregated metric for data warehouses, I'll have to find an alternative for those.

    Nice catch!

  • Report selected datastore PowerCLI

    Hello

    Please can we suggest a script or modify below a, to only generate a report for specific data storage. I don't want a report for each unique data store in vCenter, those special.

    =====================================================================

    $fileloc = "c:\output.htm".
    $body = "This is Datastore using PowerCLI export.
    $mailfrom = "e-mail address".
    $to = 'mailaddress1, mailaddress2 '.
    $subject = 'this message is sent by PowerCLI script.
    $smtpserver = "IP address of your SMTP server"

    $datastores = get-vmhost | Get-Datastore. Sort-Object Name
    $myColCurrent = @)

    {foreach ($store in $datastores)
    $myObj = "" | CapacityGB, UsedGB, PercFree, Select-Object Name, Type, ID, Accessible
    $myObj.Name = $store. Name
    $myObj.CapacityGB = '{0:n2}' f ($store.capacityMB / 1 kb)
    $myObj.UsedGB = '{0:N2}' f (($store.)) CapacityMB - $store. (FreeSpaceMB) / 1 KB)
    $myObj.PercFree = ' 0: {n} ' f (100 * $store.) Store FreeSpaceMB / $. CapacityMB)
    $myObj.Type = $store. Type
    $temp is get-view-Id $store. ID
    $myObj.ID = get-DSDevice $store
    $myObj.Accessible = $store. Accessible
    $myColCurrent += $myObj
    }

    # Export the output
    $myColCurrent | ConvertTo-Html-of title "Datastore" - body "< H2 > Information Datastore.". "< / H2 > ' | Out-file - add $fileloc

    ==========================================================================

    Thank you

    Pls change the first line

    $fileloc = "c:\output.htm".

  • PowerCLI export VM + Datastore (RDM) + DiskGB + NAAID

    Hi all

    Can someone help me get this script to pull the entire field of datastore by VM please?

    I get in trouble with the entrance of store data and naaid and how to get naaid if one machine virtual RDM devices?

    $Report = @)

    $ExportFilePath = "C:\test001.csv".

    $VMs = get - VM | Sort-Object Name

    $Datastores = get-Datastore. Select Name, Id

    $ScsiCanonicalNames = get - VM | Get-hard drive | Select name, DiskType, ScsiCanonicalName, Parent, DeviceName

    $VMHosts = get-VMHost | Select Name, Parent

    {ForEach ($VM to $VMs)

    $VMInfo = {} | Select VMName, @{N = 'File'; E={$_. Folder.Name}}, host, Cluster, data store, ScsiCanonicalName, DiskGb

    $VMInfo.VMName = $vm.name

    $VMInfo.Folder = $vm.folder

    $VMInfo.Host = $vm.host.name

    $VMInfo.Cluster = $vm.host.Parent.Name

    $VMInfo.Datastore = $vm. Data store

    $VMInfo.ScsiCanonicalName = $vm. ScsiCanonicalName

    $VMInfo.DiskGb = [math]: Round ((($vm.)) Hard drives | Measure-Object-CapacityKB property-sum). Summary * 1 k / 1 GB), 2)

    $Report += $VMInfo

    }

    $Report = $Report | Sort-Object VMName

    IF ($Report - don't "") {$Report |} Export-Csv $ExportFilePath - NoTypeInformation}

    Thank you very much, I tried this script... It's show VMName + Diskname + DiskType + Datastore NAA, but how to get the name of the folder of the by VM?

    @{N = 'File'; E={$_. Folder.Name}} isn't available on hard disk Get.

  • PowerCLI - using script VM + Datastore + Annotations?

    Can someone help me get this script to extract the field of annotations of the virtual machine please?

    Get-data center | Get-Datastore. {ForEach-Object
    $ds = $_. Name
    $_ | Get - VM | {Select-Object Name,@{n='DataStore'; e = {$ds}}
    } | Export Csv C:\VMList.csv - NoTypeInformation - UseCulture

    A virtual machine can have several annotations. I don't know if you want to combine in the same output as data warehouses. The following script lists all the names and values of the annotations of the virtual machine:

    Get-VM | ForEach-Object {
      $VM = $_
      $VM | Get-Annotation |
        ForEach-Object {
        $Report = "" | Select-Object VM,Name,Value
        $Report.VM = $VM.Name
        $Report.Name = $_.Name
        $Report.Value = $_.Value
        $Report
      }
    } | Export-Csv -Path VMAnnotations.csv -NoTypeInformation -UseCulture
    
  • What VM is including LUN via PowerCli

    Hello

    I have a SAN storage BOX connected to a SAN switch blade chassis. I have configured Powercli and get the details of the VMs and LUNS all connected on each VMware host. I want to get a list which LUN is the host that VM. I have the very large number of LUNS configured and I donot have any option instead of going through the LUN to see what virtual machines are there on this LUN. So is there a command that will give me the details what is a VM hosted on a particular LUN.

    Thank you

    Amit

    Try this.

    Get - vm | % {$_: select '}

    @{n = "VMname"; e = {$_.name}},

    @{n = "Datastore"; e = {($__|_get-datastore).name}},

    @{n = "LUN ID"; e = {($__|_get-datastore).extensiondata.info.vmfs.extent.diskname}}

    } | FT-auto

  • need help with a script of PowerCLI report IOPS / s

    I found the following script that gives me the data I want, but not ultimately I need. At the moment he puts it in the PowerCLI window, but I need to get into a csv file so it can be easily sent to others for review.

    This is the script that I found:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    Add-pssnapin VMware. VimAutomation . Core -ErrorAction SilentlyContinue

    $daysback = -30

    write-host ' What vCenter you want to connect to? -You may be prompted for a user name and password'

    write-host ""

    Se connect-VIServer -menu

    write-host ""

    $vm_data = reading-host "Enter the number of a-Org"

    write-host ""

    write-host "ARE gathering Ops / s Stats"

    write-host ""

    $vms = Get-Folder | where {$_. Name -like "*$vm_data*" } | get-vm | where {$_. PowerState -eq "PoweredOn" }

    write-host ( "{0,-70}`t{1,8}`t{2,8}`t{3,8}`t{4,8}" -f "VM", "W IOPS avg", "R IOPS avg", "W IOPS max", "R IOPS max" ) `

    ; $vms | sort | % {

    $wval = ()()()Get-Stat $_ -stat « datastore.numberWriteAveraged.average » -Start ()Get-Date). AddDays ($daysback) -Finish (Get-Date) ) | select -expandproperty Value) | measure -average -max);

    $rval = (((Get-Stat $_ -stat "datastore.numberReadAveraged.average" -Start (Get-Date). AddDays ($daysback) -Finish (Get-Date) ) | select -expandproperty Value) | measure -average -max);

    write-host ( "{0,-70}`t{1,8:N2}`t{2,8:N2}`t{3,8:N2}`t{4,8:N2}" -f $_. Name , $wval. average , $rval. average , $wval. maximum , $rval. maximum )

    }

    write-host ""

    write-host "You can copy the output by selecting the text and copy it to NotePad ++ or similar: .

    write-host " " "

    " read-host" Hit Enter to Output.

    In one, I run, I changed the "Connect-VIServer-menu" to simply plug the vCenter Server I use. I also changed line 16 to 'Get-ResourcePool' since there's not enough pools to make this work. Using the PowerCLI utility, I don't have the option that indicates on line 25. I used the export feature to create csv files in other scripts, but I can't make it work in this case. I know it's probably something simple that I'm just missing.

    I like the length of time that this script uses the information. If anything, I don't want to go back to the suite to get a better idea of what the actual maximum number what is / was. It is also necessary to have the columns for information (as he shows). If we are to refine for which metric is present, I would be ok with just having the IOPS numbers / s max in the table.

    Any guru PowerCLI have an idea?

    Try like this

    Add-pssnapin VMware.VimAutomation.Core - ErrorAction SilentlyContinue

    $daysback = - 30

    write-host "what vCenter you want to connect to? -You may be prompted for a user name and password"

    write-host "

    SE connect-VIServer-menu

    write-host "

    $vm_data = read-host "enter the number of a - Org"

    write-host "

    write-host "gathering IOPS / s Stats.

    write-host "

    $vms = get-file | where {$_.} {Name: like "* $vm_data *"} | Get - VM | where {$_.} PowerState - eq "Receptor"}

    $report = $vms | kind | % {

    $wval = (((get-Stat_$_-stat_"datastore.numberWriteAveraged.average"-Start_(Get-Date).adddays ($daysback) - Finish (Get-Date)) |))

    Select - expandproperty value) | measure - average - max);

    $rval = (((get-Stat_$_-stat_"datastore.numberReadAveraged.average"-Start_(Get-Date).adddays ($daysback) - Finish (Get-Date)) |))

    Select - expandproperty value) | measure - average - max);

    $_ | Select Name,

    @{N = "IOPS / W avg s";} E = {$wval. Average}},

    @{N = "Avg R Ops ARE / s";} E = {$rval. Average}},

    @{N = "W IOPS / s max";} {E = {$wval.maximum}}.

    @{N = "IOPS R / s max";} {E = {$rval.maximum}}

    }

    $report | Export Csv report.csv - NoTypeInformation - UseCulture

  • Migration successful by vSphere GUI but not by PowerCLI

    I have some difficulty to perform a migration using PowerCLI.  I get the error message: "unable to VACess the virtual machine configuration: Unable to access file [datastore1 (3)] jcarroll-vni-3501-server-move/jcarroll-vni-3501-server-move.vmx»       I am able to successfully migrate various VM through the Web Client vSphere, only, I get this error when trying the following PowerCLI order: PowerCLI C:\Program Files (x 86) \VMware\Infrastructure\vSphere PowerCLI > Get - VM -name jcarroll-NAV-3501-server-move | Move-VM-Destination x.x.x.x.

    Yet once, this problem does not migrate this virtual machine via the Web Client.  I checked the data store, and the file is present and correctly named.  I'm not sure of what could be the issue.

    All the info/help would be greatly appreciated.

    Thank you.

    This problem has been resolved by specifying the data store of the destination-side as well as the source host: "PowerCLI > x.x.x.y Get-VMHost | Get - VM jcarroll-NAV-3501-server-move | Move-VM-Destination x.x.x.x - Datastore ' datastore1 (3).

    The source data store has been "datastore1 (1).

  • How to - migrate VM through the vCenters using PowerCLI - bypass the validation of network

    Hello

    I'm working on an automation project, which requires that we have a VM of 1 vCenter to another.
    Each vCenter is a stand-alone instance, they are not related.

    The problem we have is that cmdlets Import-vAPP and export-VAPP are 'too' data validation.

    VAPP export works very well, however, our problems are on the part of import-vapp.

    Each vCenter uses a distributed switch, so when we run this command, we get the below error

    Import-vApp -VMHost $targetEsxhost -Source $importpath -Name $hostname -Datastore $targetDatastore -Location $targetCluster -DiskStorageFormat "THICK" -Force -ErrorAction Stop
    

    Import-TIME: 28/03/2016-09:18:29 Import-TIME host lacked any defined virtual network.

    Online: 8 char: 1

    I'm guessing that the import fails because the switches names and IDs are different on the target as on the source vCenter vCenter

    We use vCenter 5.1 and 5.5 PowerCLI for execution of our automation tools.

    What other options do I import to be successful, somehow bypassing validation of network?

    We can reconfigure our VM subsequently, but we want to just that import of fill.

    Is there any other cmdlets, that we can use, or go on the road to the API and something like Onyx allows you to spy on the vSphere Client to "make our own import-function"?

    All I know, you cannot ignore the validation, but you might take away the network.

    What I mean, check out the network configuration and store it outdoors, then try to remove the adapters for virtual machines.

    Now you should be able to migrate the virtual computer.

    During the migration, restore the vNIC and from the saved data, you have the network configuration.

  • PowerCLI - deploy VM-models from CSV

    Problems with a script.  According to me, I'm close, but still miss me something...  I don't know if PowerCLI is a matter or my knowledge lack of PowerShell.

    My PowerCLI 6 script seems to work but only at a low level.  It creates virtual machines, but does not assign the IP address or the host name to the newly created virtual computer.  Then, when it is time to apply the customization specifications, it times out or simply is not fully applied; I don't know who, as no error is spit me.  It creates the virtual machine with the correct name & changes the Group of port on which the NETWORK card will sit but that seems to be about it.  I manually tested the customization specification and model are used in the text, and it seems fine after a manual inspection.  For some reason, some information from the CSV are not used properly or at all.

    The script I have is quite long and I didn't want to ruin the page with her so I he dumped on PasteBin; hope that's ok...

    Script: http://pastebin.com/XwFHLHER

    CSV: http://pastebin.com/u59TwBu4

    Found my problem.  Everything was fine except for the line of New-VM ; He had the wrong variable for the switch -OSCustomizationSpec .  Feeling a little stupid, but it's been a long week.

    Incorrect line:

    New-VM-name $GuestVM - model $Template - location $VMFolder - OSCustomizationSpec $CustSpec - ResourcePool $Cluster - data $Datastore store

    Good line:

    New-VM-name $GuestVM - model $Template - location $VMFolder - OSCustomizationSpec $TempCustSpec - ResourcePool $Cluster - data $Datastore store

  • intermitantly script fails unless I update data store capacity properties, first of all, can anyone show me an example of a string for refreshing a PowerCLI data store

    I have a script that runs a space check before cloning a virtual machine on a data store.  Sometimes, he appears to fail (well it ends by design) and behaves as if there is not enough space.  However, if I manually update the properties of the data store by clicking on the button shown in the previous screenshot it sppears to work regularly.  Can someone please give an example if how I can essentially this key for a specific in PowerCLi data store so that I could incorperate it into my script.

    Thank you

    The following should do the same thing as the button.

    The cmdlet Get-Datastore Gets the information from the object of vSphere.

    Due to performance reasons that the info is updated on intervals, or when you ask explicitly for an update.

    $ds. ExtensionData.RefreshDatastoreStorageInfo)

Maybe you are looking for

  • Satellite A350 - driver graphics card

    Hello I have a question about the graphics card in my laptop I have radeon hd 3650 and I can not install new driver. When I download the driver from the ATI site they tell me that I have to find the drivers on the toshiba site, but I can't find them

  • How to eliminate whistling in mic records?

    How to eliminate whistling in mic records? I made a recording of a piano garage band-tailed. It sounds good in GarageBand.  When I move to iTunes there is a hiss.   Then, when I burn it to a CD even more hiss on the high-end. I don't know if the hiss

  • Need drivers 64-bit Windows 7 for Pavilion d6t Quad Edition

    The oringal had the drive did not work, changed new one, try to reinstall the system, downloaded all the drivers from the hp site, but some did not.  This is the id of the hardware: PCI\VEN_1002 & DEV_6740 & SUBSYS_1657103C & REV_00PCI\VEN_1002 & DEV

  • How can I get a new code for Mircosoft office 2010?

    My laptop had some problems so I took make repair. When I came back he was back to the orginal, a point of departure. The laptop was givin to me by my daughter and he already had the full version of Mircosoft office 2010 on it. Now he's gone and I do

  • How to stop pop up on my windows 7

    HOW TO STOP POP UP ON WINDOWS 7