Using PowerCLI to recover the capacity of volume comments data

I am using PowerCLI to declare on the volume letter and free space associated with a guest computer.  I am currently addressing this problem through the extensiondata of the VM guest and then placing the properties I want in a PSObject.

The question that I am running is that numeric values keep coming up as zero when it is inside the loop for, although they correctly resolve by themselves.  One thing I found interesting was these two upcoming properties like "System.Nullable [long"] when executing GetType(), but I don't know if that is related to the question.

The script is below, and I changed the font color on the problem section.  I'd appreciate any help.

# Pre - performance Variables

$USCulture = New-Object - TypeName System.Globalization.CultureInfo - ArgumentList "en - us".

$USCulture.NumberFormat.PercentDecimalDigits = 2

$USCulture.NumberFormat.NumberDecimalDigits = 2

Guest computers #Get

[table] $vmguests = $vmcluster | Get - VM

foreach ($vmguest to $vmguests)

{

$vmguestinfo = new-Object - TypeName System.Management.Automation.PSObject

$vmguestinfo | Add-Member - MemberType NoteProperty-Name "Hostname" - value $vmguest.extensiondata.guest.Hostname

$vmguestinfo | Add-Member - MemberType NoteProperty-Name "GuestState"-$vmguest.extensiondata.guest.GuestState value

$vmguestinfo | Add-Member - MemberType NoteProperty-Name 'GuestFullName'-$vmguest.extensiondata.guest.GuestFullName value

$vmguesthdds = $vmguest. ExtensionData.Guest.Disk

for ($i = 0; $i - lt $vmguesthdds. Length; $i++)

{

$vmguestinfo | Add-Member - MemberType NoteProperty-Name ' DiskPath$ I '-$vmguesthdds [$i] value. DiskPath

$vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' CapacityGB$ I "-value {($vmguesthdds [$i]. Capacity). ToString ("N", $USCulture)}

$vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' UsedSpaceGB$ I "-value {[System.Decimal]: Subtract ($vmguesthdds [$i].} Capacity, $vmguesthdds [$i]. FreeSpace). ToString ("N", $USCulture)}

$vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' FreeSpacePercent$ I "-value {[System.Decimal]: Divide ($vmguesthdds [$i].} FreeSpace), ($vmguesthdds [$i]. Capacity). ToString ("P", $USCulture)}

}

[table] $vmguestresults += $vmguestinfo

}

Thank you

Yes, he had a few typos in the code.

I corrected which, in the code and the attachment.

Try this one.

I'm afraid that I can't achieve this GitHub repository.

A search on your GitHub account does not return either

Tags: VMware

Similar Questions

  • How to use PowerCLI to activate the function VM NPIV and config setting?

    Hi all:

    I'm having a problem on PowerCLI.

    Can I use PowerCLI for NPIV to the VM config?

    OK, I see. This is possible with the operator "set".

    Note that the script must convert the hexadecimal number WWN in a 64-bit decimal number.

    $vmName = "MyVM"
    $nodeWWN = "28:2b:00:0c:29:00:00:07"
    $portWWN = "28:2b:00:0c:29:00:00:08"
    
    # Convert WWN string to 64-bit number
    $nodeWWN64 = [int64]("0x" + $nodeWWN.Replace(":",""))
    $portWWN64 = [int64]("0x" + $portWWN.Replace(":",""))
    
    # Activate NPIV
    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $spec.NpivDesiredNodeWwns = 0
    $spec.NpivDesiredPortWwns = 0
    $spec.NpivTemporaryDisabled = $false
    $spec.NpivWorldWideNameOp = "set"
    $spec.NpivPortWorldWideName = @($portWWN64)
    $spec.NpivNodeWorldWideName = @($nodeWWN64)
    
    $vm = Get-VM -Name $vmName
    $vm.ExtensionData.ReconfigVM($spec)
    

    You can use the cmdlet New - hard drive to attach a disc RDM. Make sure to specify a type of "gross" on the parameter - DiskType.

    You ID LUN with the parameter - DeviceName.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • using powercli to control the limit disk IOPS / s

    Hey there, I need to limit the OPS are / s of the drives connected to my virtual machines via powercli.

    I use the following command:

    Get - VM "vm_name" | Get-VMResourceConfiguration | Game-VMResourceconfiguration-DiskResourceConfiguration - configuration DiskLimitIOPerSecond 100

    But it gives an error:

    Game-VMResourceConfiguration: cannot bind parameter 'Configuration '. Could not convert the value of 'DiskResourceConfiguration' to type 'System.String '.
    ' of type 'VMware.VimAutomation.ViCore.Types.V1.VM.VMResourceConfiguration'.
    On line: 1 char: 86
    + Get - VM $vm | Get-VMResourceConfiguration | Game-VMResourceconfiguration-configuration < < < < DiskResourceConfiguration - 10 DiskLimitIOPerSecond
    0
    + CategoryInfo: InvalidArgument: (:)) [game-VMResourceConfiguration], ParameterBindingException)
    + FullyQualifiedErrorId: CannotConvertArgumentNoMessage, VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVMResourceConfiguration

    Can someone please suggest me where wrong me?

    Try it like this

    foreach($group in (Import-Csv C:\vmiopslimit.csv -UseCulture | Group-Object -Property vmName)){
      $vm = Get-VM -Name $group.Name  $spec = New-Object VMware.Vim.VirtualMachineConfigSpec  $vm.ExtensionData.Config.Hardware.Device |  where {$_ -is [VMware.Vim.VirtualDisk]} | %{
        $dev = New-Object VMware.Vim.VirtualDeviceConfigSpec    $dev.Operation = "edit"    $dev.Device = $_    $label = $_.DeviceInfo.Label    $dev.Device.StorageIOAllocation.Limit = $group.Group | where {$_.Harddisk -eq $label} | Select -ExpandProperty IOPSLimit    $spec.DeviceChange += $dev  }
      $vm.ExtensionData.ReconfigVM_Task($spec)
    }
    

    The CSV file should look like this

    "vmName", "hard disk", "IOPSLimit".
    'VM1', ' Hard disk 1 ","50"
    'VM1', ' Hard disk 2 ","75"

    'VM2', ' Hard disk 1 ","75"

    'Computer', ' Hard disk 1 ", 3 '35"
    'Computer', ' Hard disk 2 ", 3 '55.

    'Computer', ' disk hard 3 ", 3"65"

  • cold backup can use archivelog to recover the database to the point of failure?

    Hello

    I have little doubts. In any DB saying we have following conditions:

    (1) DB is running in ARCHIVELOG mode.
    (2) cold backup is performed every Sunday.
    (3) no backups hot or the RMAN backup is taken.

    so if any failure occurs during the week say Friday. can recover us our database to the point of failure with cold backup? If yes then pls specify the steps how to do it.

    Archiving log could apply on cold backup?


    Thank you
    Shailesh

    Yes. Just make sure that you use "with the HELP of BACKUP CONTROLFILE' so that Oracle ignores the sequence numbers and the SNA in the controlfile and guard"rolling-forward"until the last archivelog that provide you.
    If you have not lost all over again the logs files and want a complete recovery, you must provide log redo file names "as if they have been archived" after applying the last archivelog. This way, you will be able to achieve a complete recovery.
    Of course, you will need to OPEN RESETLOGS.

  • Using PowerCli to display the location of the folder vcentre

    Hello

    I adjusted began using the Cli power today. I managed to get some info on the internet but I am of course to have a problem with the script im its simple but at this stage I don't know enough about it.

    Basically I want thescript to output to a csv file with the name of the Virtual Machine, Datastore, host and his VCentre folder location.

    Everything is be filled except the get-file colum who im hoping will indicate the location of the folder VCentre

    Get - VM | Select Name, @{N = 'Cluster'; {E = {Get-Cluster - VM $_}}, '
    @{N = "ESX host"; {E = {Get-VMHost - VM $_}}, '
    @{N = "VICont"; {E = {Get-file - VM $_}}, '
    @{N = "Datastore"; {E = {Get-Datastore - VM $_}} | `
    Export-Csv - NoTypeInformation C:\VM_CLuster_Host_Datastore1.csv

    Thank you very much

    Ryan

    With recursion a bit, you can go a long way

    Get-VM | Select-Object -property Name,
    @{N="Cluster";E={$_.VMhost.Parent}}, @{N="ESX Host";E={$_.VMHost}}, @{N="VICont";E={
      $nodes = @()
      $obj = $_.ExtensionData  while ($obj.Parent){
        $obj = Get-View $obj.Parent    if("Datacenters","vm" -notcontains $obj.Name){
          $nodes += $obj.Name    }
      }
      [string]::Join('/',$nodes[($nodes.Count - 1)..0])}},@{N="Datastore";E={Get-Datastore -VM $_}} |
    Export-Csv -NoTypeInformation C:\VM_CLuster_Host_Datastore1.csv
    
  • How to use PowerCLI to change the connection of network of 60 virtual machines

    Hello

    I have several virtual machines of XenDesktop with similar names and currently the same network, but I want to be on a different network. Here are the details:

    For my virtual machines, appointed XD-W7-01 by XD-W7-60, on 1 network adapter, they are all currently on 'Network VDI of Xen Production' for their connection network. I want that they all be changed to 'network of VDI Xen Test '. can you give me the script to make an and I can certainly understand the rest. Thank you very much in advance.

    Hello, MarchTheMonth-

    Welcome to the communities.

    You can do this quite easily by using the cmdlet Set-NetworkAdapter , as:

    ## for one VMGet-VM XD-W7-01 | Get-NetworkAdapter -Name "Network adapter 1" | Set-NetworkAdapter -NetworkName "Xen Test VDI Network" -WhatIf
    

    (remove the '-WhatIf "do actually change).  So, for all the machines of sixty, it would be something like:

    ## for all of 1-60Get-VM (1..60 | %{"XD-W7-{0:d2}" -f $_}) | Get-NetworkAdapter -Name "Network adapter 1" | Set-NetworkAdapter -NetworkName "Xen Test VDI Network" -WhatIf
    

    Yet once you take off the coast of the - WhatIf to change.  What to do for you?

  • Can be used as part of the regular expression user input data?

    Hello!!

    Yet another querry me... This time want to know is possible to use the chain of user input in the context of speech reqular for instant search... I am aiming to add the search functionality in my game... Where I m going to have several items available in the list... what I intend is to have a text box where I accept user input and instant search still a noob in AS3... so, if using RegExp my goal?

    Suggestions please...

    Thanks in advance...

    Yes - you can build a regular expression like this:

    new RegExp("bob", "gi");

  • Need help to report on the configurations of the virtual machine using PowerCLI

    Hi guys,.

    I try to shoot down vCenter virtual computer configuration details and am not having much luck with vCPU multicore machines.

    Looking at the lists of VMS in vSphere Client, it offers a column "Number of CPU" basis and does not include any other granularity (i.e. in terms of casings & carrots as opposed to simply 'CPU Count').

    I thought that maybe I have better luck using PowerCLI and essentially, the cmdlet "Get - VM" has the kind of information I'm looking for, but I find that it lacks a bit when it comes to vCPU details.  Essentially, it turns out that does not do much better than the list of virtual machines in vSphere Client because it produces only a "CPU Num" value, which is not particularly useful.

    For example, if "processors Num" 4, that '4' means?  This could mean one of the following:

    • 1 x 4 drivers
    • Core 2 x 2
    • Basic 4 x 1

    I hope someone out there can help produce me a list of virtual machines with details of configuration that includes both sockets & carrots for vCPU?

    Thanks in advance!

    Try like this

    Get-VM | Select Name, @{N="CPU";E={$_.ExtensionData.Config.hardware.numCPU/$_.ExtensionData.Config.hardware.numCoresPerSocket}}, @{N="Core per CPU";E={$_.ExtensionData.Config.hardware.numCoresPerSocket}}
    
  • Migration of vm to another folder using powercli

    Hi guys,.

    I'm migrating some hosts between 2 different virtual centers and will have all the entrants of the virtual machine on the new virtual Center placed by default in the folder "Discovered virtual machine."  I'm trying to use powercli to move the virtual machine linux to a specific folder and windows of the virtual machine to a different folder.  However, I was unable to do so and was hoping that someone here can help.  I am new to using powercli.  Here is what I tried:

    Get-Datacenter "XXX" | Get folder "Discovered virtual machine | Get - vm | Where-Object {$_.} PowerState - eq "Receptor"} | Get-vmguest | Where-Object {$_.} {OSFullName-like "* Linux *"} | Move-VM-Destination 'Linux '.

    Looks like that move-vm does not like the input it receives from get-vmguest.  However, it is as the input to get - vm, but I can't seem to get a list of virtual machines linux just by using the get - vm command.  Any help would be appreciated.

    Thank you

    -Simran

    Get-Datacenter "XXX" | Get folder "Discovered virtual machine | Get - vm | Where-Object {$_.} PowerState - eq "Receptor" - and $_. {ExtensionData.Config.GuestFullName - like ' * Linux * "} | Move-VM-Destination 'Linux '.

  • PowerCLI to find the host added in vcenter in the last 12 months

    Hello

    Can we use Powercli to find the host added in vcenter in the last 12 months

    Thank you

    The Get-VIEvent cmdlet and look for the HostAddedEvent.

    Get-VIEvent-beginning (Get-Date). AddYears(-1) - MaxSamples ([int]: MaxValue) |

    Where {$_-is [VMware.Vim.HostAddedEvent]}

    You can also use my Get-VIEventPlus function.

    Get-VIEventPlus-beginning (Get-Date). AddYears(-1) - EventType HostAddedEvent

  • How to recover the data store of VMware using EQL Volume snapshot (smart copy)?

    Hi, I use VMware Std 5.1.0b on Dell EQL 6100 series.

    I have a question where my datastore (2 VMs) VM are stored in one of the Volumes EQL. I had created smart copies weekly.

    I tried to recover by creating a volume "cloned" by using one of the smart copies. That's why I would have 2 exact same volumes in EQL (one is updated and the other is 1 week old).

    I can rename them running EQL EQL centenarians. But it doesn't seem to be a way for me to get old EQL volume to vCenter.

    -J' have re-scanned the ESXi for databases and I tried to add, but he can't just see volumes

    Is there a step I missed that "deletes" and ID that distinguishes EQL-current and old EQL?

    When ASM creates stereotypes that they are defined in read ONLY. Make sure that you change this read-write in the first group Manager graphical user interface.  Then rescan.  The LVM. EnableResignature will not work unless it is read-write.

    -joe

  • Windows 8.1 lost the capacity of the volume, brightness keyboard and not let me download my Norton software.

    Original title: windows 8.1

    upgraded to 8.1 from 8 on a new Toshiba laptop purchased in may 2013.

    with 8.1 lost the capacity of the volume, brightness keyboard and not let me download my Norton software.
    No matter what is said, Adobe flash does NOT work in windows 8 and won't let me not download it from adobe.
    summer on the phone with technical support both windows and Toshiba, each fingers towards each other, saying that it will take a few months to coordinate the software updates.
    updates on this?

    8.1 is a beta and has a lot OF known issues under development and lot of unknown problems that have not yet been discovered.  It should be downloaded only by those who are comfortable, dealing with the problems of a trial version of the software.

    Lost the brightness controls and volume: do you need a driver. Your computer manufacturer may not have built their hardware drivers for Windows 8.1 control again.  They are not forced to do it to the beta-test system, so "use at your own risk.

    "Unable to download Norton".  What is the error you get?  Is this a problem with the download from the Norton site, or the installation process it?

    "Adobe Flash does not work".  Yes it does, it is integrated and you don't need to install it.  Just go to any Web site that uses flash and it will take care of itself.

    "Toshiba and Microsoft Point fingers"  Toshiba is not necessary to press the test system for windows 8.1, and Microsoft provides no support for the test software.  That is why they you warned that the 8.1 has many known and unknown problems and warned against install unless you like to manipulate and test out these problems.

    Looks like you need back to Windows 8 and wait for the final version.

  • Want T15 - J100 Quad Edition Tou: recover the BIOS of the laptop using an external storage device

    So, from the start of my screen is empty and Caps Lock flashes 2 times.  I tried the Windows key + B + power key without success as indicted here:

    http://support.HP.com/us-en/document/c02693833?JumpID=reg_r1002_usen_c-001_title_r0003

    I tried to recover the BIOS with an external storage device but HP's Software and driver download page does not have BIOS updated.  I've updated for Windows 10.

    Where is the BIOS update that is supposed to be here? :

    http://support.HP.com/us-en/drivers/selfservice/HP-envy-15-J100-Quad-Edition-Notebook-PC-series/6521...

    This model seems to have a lot of problems with what I find it everywhere on the internet, but the solutions all return to the download of the update of the BIOS.  I noticed that I can download an update for Windows 8.1.  Are there not one for Windows 10 yet?  Can I use the 8.1?

    The BIOS in the list of drivers of Windows 8 is the last exit for your model. You can use it regardless of the operating system because the BIOS recovery is run outside of Windows.

    BTW-to help the Windows key + B keys. When you press and release the power button / continue to hold the buttons for a few seconds see if BIOS recovery screen appears. I know that it is different from the document - but try it.

  • I use Live Mail client and SSL, but I can't recover the messages in my subfolders in my Hotmail account, how can I do this?

    I use Live Mail client and SSL, but I can't recover the messages in my subfolders in my Hotmail account, how can I do this? I can use a web browser to display, but Live Mail client only update the subfolders, only the Inbox.

    View all Windows Live and Hotmail questions in the appropriate forum found here:
    http://windowslivehelp.com/

  • Can I dwnld copy of OS WinXPpro, burn a DVD to boot on the floppy drive to recover the deadly accident of en using F12 select Boot Drive? I have the s/n Auth/softwr.

    Original title: ask again once-> can I dwnld copy of OS WinXPpro, burn a DVD to boot on the floppy drive to recover the deadly accident of en using F12 select Boot Drive? I have the s/n Auth/softwr.

    Help.

    Dell laptop lock-loops to start in the black & white screen asking me to
    Then select Startup disk
    "dailies" to the next screen which expires just by itself, then
    place a line of BACK code screen, then freezes.
    So, at the start, I can see the option to choose F12 drive start from;
    and of course, I would choose FDD DVD player
    IF I HAD A DRIVE W / THE O/S ON THIS SUBJECT.
    But as John Belushi used to say: "NO-o-o-o-o-o-o!"
    So, can I download a copy of an OEM version of Windows XP - pro (same as mine) and then burn, which load in the floppy drive on the Dell, State zipped/compressed and have the
    BIOS see the disk in the floppy drive and perform a reload of the OS?
    I need to download on my other one cmptr, burn it being dwnld (cause that is a Mac Intel DuoCore).
    And if I can get this Dell pro M/S Windows XP right back, otherwise, we are sick of the trash, THAT M/S imposes on the market as a "finished".
    Help, pls.

    Hello

    You can access the link: how to replace Microsoft or hardware, packs software service to order and replace product manuals: http://support.microsoft.com/kb/326246

Maybe you are looking for

  • iMovie on El Capitan 10.11.2 crashes when opening, indicating the download of a project.

    iMovie on El Capitan 10.11.2 crashes when opening, indicating the download of a project. You have to force quit.

  • How to change the background color of string programmatically?

    How to change the background color of string programmatically?

  • HP 2000 power on password?

    My aunt did something to his computer and now can't start without a password she knows not to market. After three tries, he gets safe and gives this code system off 54001581. It's a hp 2000 model # 2d19wm

  • enable uac

    I ran the Microsoft fix Center because I think someone tries or has some control over my pc. When I open the browser, it shows my preference for a city that I do not live and I have changed it several times. When I connect, it does the same thing. Af

  • C1900101-20017

    Hi can anyone help me im trying to upgrade to windows 10 it will lower the load and then seems to freeze left with logo 10 windows must shut down the computer and it comes up with the error FAILED C1900101-20017