Get-view datastore and get-function data store

Hey, my first time posting here.

Creating a function which takes as input pipeline and processes that each entry through process in a function. I want the function to be able to take the 'get - view - viewtype datastore' and 'get-datastore' as input.

Obtained in what concerns obtaining the opinion of the GET and get-datastore work separately in the service, but when I want the function to be able to take one or the other input that I can't make it work.

Here is the function at this moment, not really work for one of the entries.

Function Get-DatastoreSpace () {}
[cmdletbinding()]
(param
[Parameter (mandatory = $true,)]
ValueFromPipeline = $true)]
$Datastore
)

BEGIN {$ReportDatastore = @ ()}

{IN PROCESS

$row = "" | Select-Object Datastore_name, Datastore_Freespace_GB, Datastore_type, Datastore_Capacity_GB
$row. Datastore_name = $_.name
$row. Datastore_type = $_.type
$row. Datastore_Capacity_GB = [math]: tour ($_.) Capacity / 1 gb, 3)
$row. Datastore_Freespace_GB = [math]: tour ($_.) FreeSpace / 1 gb, 3)

$ReportDatastore += $row

}

END {$ReportDatastore}

}

Any ideas on how to do this?

Thanks in advance

Eirik

Check the type of the object in the variable $datastore.

Something like that

if($datastore -is [VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl]){
# From Get-Datastore
}
elseif($datastore -is [VMware.Vim.Datastore]){
# From Get-View -ViewType Datastore
}
else{
# Wrong object type
}

Tags: VMware

Similar Questions

  • get the data store with details of mapped cluster

    Hi with the script below, I am able to do data store maps on which the cluster and its host details... but I'm having multiple LUNS how to write for everyone to get to each store data below the output...

    Get-data store 'testdatastore ' | Get-VMHost | Name,@{N="cluster select '; E={$_| Get-Cluster}}, version

    Output:

    Version of cluster name

    10.0.0.0 testcluster 5.1.0

    Desired output:

    I need the name of output data store because I check for several data stores... can someone help me to get .csv exit foreach datastore as below

    Data name cluster version store

    testdatastore 10.0.0.0 testcluster 5.1.0

    testdatastore 110.0.0.1 testcluster2 5.1.0

    What type of data store?

    I'm asking because there is no mentioned properties (. ExtensionData.Info.Vmfs.Extent) for data warehouses is of type NFS:

    PowerCLI C:\Windows\system32 > ((get-datastore_iscsi*).ExtensionData.Info.Vmfs.Extent). Diskname

    NAA.60a9800042594835695d453439742f53

    PowerCLI C:\Windows\system32 > ((get-datastore_NFS).ExtensionData.Info.Vmfs.Extent). Diskname

    So, you'll need probably something like this:

    Get-Datastore. % { $ds=$_; Get-VMHost - Datastore $ds | Select @{N = 'Data store name'; E = {$ds. Name}},@{N="NAA '; E = {if($ds.) Type - such as 'NFS') {'NFS'} elseif($ds.) Type - as "VMFS") {[String]: join (", ($ds.ExtensionData.Info.Vmfs.Extent|% {$_.}))} DISKNAME}))}}}, name, @{N = 'cluster'; E={$_| {Get-Cluster}}, version}

  • PowerCLI 5.0 - get the data store and VM information

    I am trying to reach the list of virtual machines and their data warehouses in a specific cluster. It seems that the name of the data store does not... Any ideas?

    PowerCLI C:\Program Files (x 86) \VMware\Infrastructure\vSphere PowerCLI > Get-Cluster "NOMCLUSTER" | Get-VM-name * | Get-hard drive | Export-Csv - NoTypeInform

    c:\Scripts\***.csv creation

    Get-Cluster * | Get - VM | Select Name,
    @{N = 'Cluster'; {E = {Get-Cluster - VM $_}}, '

    @{N = "ESX host"; {E = {Get-VMHost - VM $_}}, '

    @{N = "Datastore"; E = {Get-Datastore - VM
    $_}}

  • get the names of Get-ScsiLun data store

    Im stuck here...  Can anyone help me to get the names of data store for storage devices using the script below? My requirement is to get the naa (ConsoleDeviceName) address and the names of data store for each storage device.

    $esxName = "esxsrv1".

    $report = @)

    Get-ScsiLun - VmHost $esxName - LunType "disk". %{

    $row = "" | Select the host, ConsoleDeviceName, model, provider

    $row.host = $esxName

    $row. ConsoleDeviceName = $_. ConsoleDeviceName

    $row.vendor = $_. Name of the vendor

    $row.model = $_. Model

    $report += $row

    }

    $report | Export Csv c:\Temp\results.csv - NoTypeInformation

    Thank you very much, Kev - o

    Try it like this

    $esxName = "esxsrv1"
    
    $dsTab = @{}
    foreach($ds in (Get-Datastore -VMHost $esxName | where {$_.Type -eq "vmfs"})){
        $ds.Extensiondata.Info.Vmfs.Extent | %{
            $dsTab[$_.DiskName] = $ds.Name
        }
    }
    
    $report = @()
    Get-ScsiLun -VmHost $esxName -LunType "disk" | %{
    
        $row = "" | Select Host, ConsoleDeviceName, Vendor, Model, Datastore    $row.host = $esxName    $row.ConsoleDeviceName = $_.ConsoleDeviceName
        $row.vendor = $_.Vendor
        $row.model = $_.Model
        $row.Datastore = &{
            if($dsTab.ContainsKey($_.CanonicalName)){
                $dsTab[$_.CanonicalName]
            }
        }
        $report += $row}
    
    $report |Export-Csv c:\Temp\results.csv -NoTypeInformation
    

    The script begins by creating a hash table where he maps the CanonicalName with the DatastoreName.

    In the 2nd part of the script of the hash table is used to find the DatastoreName through the CanonicalName.

  • Cancellation of the assignment and reassign the data store by using different LUNS that datastore has not appeared.

    Hi all

    I have a data store after vdisk1 I have not assigned the vdisk to data store and reread the esxserver, the data store has disappeared.

    Again, I assigned the vdisk using the same number of logical unit as before and reread the esxserver, datastore appeared again return.

    But if I use a different assignment vdisk lun and on a new analysis of data store does not appear.

    Can someone tell me if the LUN must be even to see the store of data back again.

    If so why. ?

    Is there a vmware documentation to substantiate this claim.

    concerning

    Neela

    What do you mean by vdisk1?  The data store are stored as metadata on the LUN, when is formatted VMFS.  If you remove the LUN the VMFS is sitting on, then Yes, the data store will disappear.  If you only remove the vmdk who lives on this data store, then no, the data store must remain as it is, and you should be able to move the vmdk on the data store as needed.

    -KjB

    VMware vExpert

  • Gets the data store size

    Hello, I do not know if here is righ place to my question if not please tell me where I can post it.

    I am attemping the information on the data store size by CLI with order tracking.

    c:\Program Files (x 86) \VMware\VMware vSphere CLI\bin > vmkfstools.pl "C:\Prograare\VMware vSphere CLI\Perl\bin\perl.exe" - serve
    queryfs-/ vmfs/volumes/v7ksas17 - vihost jvelnx - vm01.tigre.in

    work of starts but he asks me user and password for the moment that I run.

    I want to move this authentication directly by the CLI only after "ENTER".

    Is it possible? How?

    Thank you

    If you use the vCLI under Windows, you can use the passthroughauth - assuming you connect in Windows system with the same credentials that you would login to your vSphere environment.

    If this isn't the case, you can also specify the user name and password by specifying it only on the same command:

    for example

    vmkfstools.pl - Server [VC] - queryfs/vmfs/volumes/v7ksas17 - vihost jvelnx - vm01.tigre.in - username [USER] - password [COL]

    Also, you can create a session file and then specify that, in this way, you don't need to have your credentials in clear text.

    You can take a look at the additional documentation by auth options here - http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vcli.getstart.doc_50%2Fcli_run_remote.5.3.html

  • Try to re-signing and mount a data store

    Hi all

    I'm stuck trying to develop a "workflow" and hoping you can help. We need to make a daily DR copy of a production database and edit this copy on another virtual machine. The database feeds a hard with his own logic unit number and is heavily used, so we can suspend only wrote a few minutes.


    Here are the high-level workflow:

    1. Suspend the entries in the database
    2. Create a virtual copy (snapshot) of the LUN on our 3PAR
    3. Resume database entries
    4. Export (present) the virtual copy of the 3PAR to the ESXi cluster
    5. A rescan storage on all hosts in the cluster
    6. Add the LUN and re-signature of the data store
    7. Mount the VMDK from the new LUN to the VM test

    I fight a bit to make the portion of ESXi work. I can re-scan storage successfully on my host, but I'm not able to go up and re-signing of the data store newly discovered. Onyx told me to use resignatureUnresolvedVmfsVolume_Task , but the action failed with "TypeError: cannot find the resignatureUnresolvedVmfsVolume_Task function in the object (Instance) DynamicWrapper: [VcHostSystem]-[class com.vmware.vmo.plugin.vi4.model.VimHostSystem]" I run 5.5.2 vRO/vCO and don't have the library installed vi4 nor do I have all the actions that will be re-signing a volume.

    So I wonder, ResignatureUnresolvedVmfsVolume_Task has been deprecated and replaced by something else? Or did someone knows a library/plugin that I can add to vRO who will give me the opportunity to re-signing a data store?

    Thanks in advance for any help.

    See you soon!

    Hello

    The error message, it seems you are trying to call the method resignatureUnresolvedVmfsVolume_Task() on the object of type VcHostSystem. something like that

    var task = hostSystem.resignatureUnresolvedVmfsVolume_Task(spec);
    

    The problem is that resignatureUnresolvedVmfsVolume_Task() is not a method of type VcHostSystem, but in VcHostDatastoreSystemcharacters, therefore, you get this error.

    To fix it, you must obtain an object of type VcHostDatastoreSystem. Research in the API Explorer, you should be able to get VcHostDatastoreSystem object VcHostSystem object through the configManager property (which returns an object of type VcHostConfigManager), then property of datastoreSystem . Something like the following code:

    var task = hostSystem.configManager.datastoreSystem.resignatureUnresolvedVmfsVolume_Task(spec);
    

    I don't have a good environment to test, but it should work.

    I hope this helps.

  • Adding/viewing ESX hosts the local data store in vCenter

    Hey all,.

    I am pleased to join these forms and hope I have don't get dessu down for not having a cert VM (I train hard knowledge where and how get it)

    I have recently graduated from networking and am on the fast track in my new career. Now things are as clear as possible so I will try to fill as much

    ESXi 1 - Dell G6, running, 1065491 5.1.0

    Storage adapter - Smart Array P410i

    vmhba0

    Details - Serial Attached SCSI disk HP, ID (naa. #...), name of Runtime: vmhba1:c0:T0:L0, mounted the Non - SSD, block adapter, 1 TB)

    ESXi 2 - Dell G7 5.1.0 running, 1065491

    Storage adapter - Smart Array P410i

    Details-HP Serial Attached SCSI Disk, ID (naa. #...), name of Runtime: vmhba1:c0:T0:L1, mounted the Non - SSD, block adapter, 1 TB)

    vCenter - Win Server 2008 r2 (working on the features of powershell to work with packages from CodePLex)

    ESXi hosts in a single datacenter, with one single Cluster... in this cluster is a SAN that the two hosts can access without problem

    When I click on Cluster 1-> summary-> Storage (local storage shows ESXi 1 and SAN storage) NO ESXi 2 of local storage.

    When I click on ESXi 1 host in vCenter and then click on summary or Configuration (Storage)... it will show the SAN and hosts local storage

    When I click on ESXi 2 host in vCenter and then click summary or Configuration (Storage)... it will show the SAN and NOT hosts local storage

    How can question I view and manage local storage of 2 ESX via vCenter?

    At the moment I have to hand, log in to ESX 2 via vSphere thickclient and see its local data store.

    I was talkin to some people on #vmware in IRC, but can't seem to understand why... is something mmiss configured? I thought that this would have been a no-brainer... I tried to 'find new warehouses of data' on the ESX 2 in vCenter, no dice.

    Help

    Welcome to the community - I would try to remove the host to vCenter and see if you can see the local storage.

  • Name of list and MPIO policy data store

    How to add the name of data instead of the CanonicalName store using the used below command:

    Get-vmhost | Get-Datastore. Get-ScsiLun | SELECT VMHost, Multipathpolicy, seller, model CanonicalName

    Try something like that.

    For each extension of a data store, the script lists the LUN properties.

    $report =@()
    
    foreach($esx in get-vmhost){
        foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){
            foreach($ds in (Get-Datastore -VMHost $esx)){
                $ds.ExtensionData.Info.Vmfs.Extent | %{
                    if($_.diskName -eq $lun.CanonicalName){
                        $row = "" | Select Host,DS,CanonicalName,Vendor,Model,CapacityMB,MultiPathPolicy
                        $row.Host = $esx.Name
                        $row.DS = $ds.Name
                        $row.CanonicalName = $lun.CanonicalName
                        $row.Vendor = $lun.Vendor
                        $row.Model = $lun.Model
                        $row.CapacityMB = $lun.CapacityMB
                        $row.MultiPathPolicy = $lun.MultipathPolicy
                        $report += $row                }
                }
            }
        }
    }
    $report
    
  • ESXi and VMFS imaging data store

    I need to mass produce ESXi USB key as well as a large store of data VMFS.  We know good products or procedures to go on a USB stick of imagery, as well as imaging ESXi a VMFS datastore.

    For the stick, I'd use dd on Linux machine.

    For the data store, you can use a disk imaging tool like Capitol or Ghost or you export your VMS and import destination.

    Once the image is created (or virtual machines are exported) you can easily copy them.

    André

  • Rename the VM and labels in data store locations

    I remember my days with vSphere 4 x that I had to rename a virtual computer once.   But, the vmdk/vmx partner, files etc. and even the record in the data store has not changed.   However, when I did a Migration of vStorage in another store of data with the virtual machine also migrate to a new host when it was finished... all sync'd up.   or that's how I remember it.

    But, I'm now told my my virtual colleague that rename a virtual machine and to migrate to vStorage and VM migration to a new host WILL NOT synchronize the naming and lables.  is that correct?  I am almost sure that it worked in vSphere 4.

    It was behavior that was introduced in vSphere 5. It has since been resolved in Vcenter Server 5.0 Update 2 and 5.1 Update1. See the article I've linked below:

    VMware KB: vSphere 5.x Storage vMotion is not renaming the files of virtual machines at the end of migration

  • Host virtual computer and Migration of data store

    I'm curious. I have an environment with Cisco UCS UC servers without them. Due to they are C-Series all storage is local for UC virtual machines run. I'll add some of the UCS C-Series servers and you want to move two of my current C-Series server CPU virtual machines to the new. I have the license Enterprise Plus 4.1 for all servers and execution of vCenter. The migration will be basicall move local data store to store local data as well under the name from host to host. My plan is to turn off the virtual machines and migrate both host and the data store at the same time. I have groups of ports built as follows:

    Port of VMKernerl groups:

    -Storage (for future shared storage)

    -vMotion

    -PI

    -ESXi Mgmt

    Virtual machine:

    -CPU VMS

    -Machines virtual server

    My overall question is during this migration takes place this network (or a group of Port) will be the traffic go anywhere for the move? My guess is because it is the local storage, it will use the Mgmt. ESXi

    Thank you!

    If the virtual machine will be moved to store Local data to store common data shared through 2 esxi host, then the storage shared for local storage.

    So this will be the case through network vMotion and not via the management network.

    But you can enable vmotion on management network itself. If you have configured like this then yes communication will be via the management via vmotion network IPkerenel active network.

  • View online and MAX function

    I've got this task somewhat complex combination of different matches from all tables in the columns of each table. I need advice to fix this.

    Here's what I have:

    Select
    DM.wtdocumentnumber 'DOC_NUMBER. "
    A4. TITLE "DOC_TITLE."
    A4. DESCRIPTION "DOC_DESC."
    OBH. UPDATESTAMPA2 "RELEASE_DATE".
    org. NAMECONTAINERINFO "NOM_ORG"
    Of
    wcadmin.orgcontainer ORG,
    wcadmin. PAPER A4,
    (SELECT A4. Title, max (OBH. UPDATESTAMPA2)
    FOR wcadmin. PAPER A4, wcadmin. OBJECTHISTORY ENTERED
    Group by the A4. Title) OBH
    where
    ((ORG. NAMECONTAINERINFO = 'ITT ACD' and
    A4.ida2a2 = OBH.ida3a5 (+)
    order by
    1,2,5;


    There is something wrong with the way I'm referenecing these tables, but I can't quite put my finger on it.
    The relationship between the tables is as follows:
    I want to go back to the last OBJECTHISTORY. UPDATESTAMPA2 that corresponds to the DOCUMENT. Title, so basically, the latest document.
    The question is, the release date of each document is listed on the OBJECTHISTORY table. UPDATESTAMPA2, whether they are more recent or not. The only way would be to get the maximum objecthistory.ida3a5 and which corresponds to wtdocument.ida2a2. Then, like that I get only a date for each document.

    I looked in inline mode and the max and the Panel, but do not know enough of SQL and oracle to understand this.

    If anyone can help with this would be greatly appreciated

    Thank you

    Great, you are welcome and if you could mark this thread as answered thanks ;)

  • View threads AND grouped by date/conversation

    Hello

    I try to have messages see the thunderbird grouped by date (with a thread on today, yesterday, last week, etc.) and within these threads, see email conversations. A conversation that began three weeks ago, but has received a new email today is expected to manifest itself in the thread today, but from the first email of the conversation.
    I did not understand if it is possible, as grouped by (Date) and Threads are mutually exclusive. Any ideas?

    Thank you

    As you say, it is there only one group so at the time. So I guess that your out of luck.

    You could fill a better bug report and see if one of the developers interested. https://Bugzilla.Mozilla.org/

  • Load the view definitions in the short data store

    Hi all

    If I was able to export the view definitions that there was error on next import
    «"substring on column 5 26 line - ' String index out of range:-161 '"»

    I tried the graphic loadviewdefinitions of the QuickStart project and it came with the same error. I also deleted the definition of the base xml view but it error persists.

    Thank you

    Please visit the wiki updated post for how to import the display configuration in the format provided by the design of view export configuration template:

    https://wikis.Oracle.com/display/endecainformationdiscovery/import+view+configuration

    -Ryan

Maybe you are looking for