Script to collect the VM name and total size on disk

I'm trying to find a script that will display the following information:

  • Name of the virtual machine
  • The total size of the VM (vmdk)

I thought I saw one here before, but can't seem to find it anywhere.  Any help would be greatly appreciated!

You get the error by using the function, because the function expects an object of VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl and you give a VMware.Vim.VirtualMachine object. If you change your part of the code in:

# Connect to VIServer
Connect-VIServer $VIServer

#Initialise Array
$Report = @()

# Gather VM Size Information
    $AllVMs = Get-VM
    ForEach ($vm in $AllVMs){
            $Size = Get-VmSize($vm)
        }
        $Report += $Size

$Report | Export-Csv "C:\VMDiskSize.csv"

# Disconnect from VIServer
Disconnect-VIServer $VIServer -Confirm:$False

He will not give an error. But this does not also give the desired output because it will give you the total size of the disk of all virtual machines.

You get the expected result:

# Connect to VIServer
Connect-VIServer $VIServer

#Initialise Array
$Report = @()

# Gather VM Size Information
$AllVMs = Get-VM
ForEach ($vm in $AllVMs){
    $Row = "" | Select-Object VM,Size
    $Row.VM = $vm.Name
    $Row.Size = (Get-VmSize($vm))/1GB
    $Report += $Row
}

$Report | Export-Csv "C:\VMDiskSize.csv"

# Disconnect from VIServer
Disconnect-VIServer $VIServer -Confirm:$False

Tags: VMware

Similar Questions

  • PowerCLI Script to change the DNS servers and domain name

    Hello

    Brand new to PowerCLI, I'm trying to create a script that will change the domain name and the DNS servers of my ESXi servers. I found that I need to update the Vmware.Vim.HostDnsConfig to update these settings. I created the following script and the following error.

    $config = new-Object VMware.Vim.HostDnsConfig
    $config.domainName = "new.domain.com".
    $config.address = new-Object System.String [] (2)
    $config.address [0] = "10.69.69.80".
    $config.address [1] = "10.69.70.80".

    _this $ = get-view-Id "HostNetworkSystem-networkSystem.

    _this $. UpdateDnsConfig ($config)

    You can not call a method on a null value expression.

    Line: 1 char: 23

    + $_C. UpdateDnsConfig < < < < ($config)

    + CategoryInfo: InvalidOperation: (UpdateDnsConfig:String)], RuntimeException

    + FullyQualifiedErrorId: InvokeMethodOnNull

    I guessed the error message that I need to a value in the host name, I do not need to change the host name. So I create a variable to remove the host name and place it in the $config. Line received host name but still a mistake because the variable is pulling more information that I need.

    $hostname = get-VMHost | Select name

    $config. Hostname = $hostname

    When I insert the above code I have an error.

    Exception by calling 'UpdateDnsConfig' with '1' or the arguments: ' year error occurred during the configuration of the host.
    Line: 1 char: 23
    + $_C. UpdateDnsConfig < < < < ($config)
    + CategoryInfo: NotSpecified: (:)) [], MethodInvocationException)
    + FullyQualifiedErrorId: DotNetMethodException

    When I look at the $config I see the following.

    DHCP: false
    VirtualNicDevice:
    HostName: @{Name = ESXI01}
    Domain name: new.domain.com
    Address: {10.69.69.80, 10.69.70.80}
    SearchDomain:
    DynamicType:
    DynamicProperty:

    Of course the @{Name = ESXI01} will not work. Someone can explain how to get a host name in a variable and pass it to the Config.Hostname?

    You should be able to do easily by using the command "set-vmhostnetwork.

    I don't think that you can just write to VMWare.Vim.HostDnsConfig.

  • Extract the first name and last names of a string

    Hello people,
    I am trying to extract the last name, first name, first name and initial of some names of students for a report. I have some success with the first name and the first names, but have some difficulty to come with the other two. I use Oracle 9i and would like to come with the SQL.

    Script to create the table:
    create table grad_student_tb
    (student_id varchar2(3) primary key,
     salutation varchar2(4),
     student_name   varchar2(60));
    Script to insert records into the table:
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('001','Mr','Adams,Robert Murphy');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('002','Mr','Green,Eric Craig');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('003','Miss','Brown,Jennifer William H');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('004','Mr','Adams,Michael William H');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('005','Miss','White,Snow');
    Here's what I would like on my report:
    Student ID   First Middle Name    Last Name   First Name   Initial
    ==================================================================
    001          Robert Murphy        Adams       Robert       M
    002          Eric Craig           Green       Eric         C
    003          Jennifer William H   Brown       Jennifer     W
    004          Michael William H    Adams       Michael      W
    005          Snow                 White       Snow
    Currently my SQL looks like this:
    select student_id,
           SUBSTR(student_name, INSTR(student_name,',')+1, LENGTH(student_name)) first_middle_name,
           SUBSTR(student_name,1, INSTR(student_name,',')-1) last_name
    from   grad_student_tb;
    Output:
    STUDENT_ID FIRST_MIDDLE_NAME                                            LAST_NAME                                                    
    ---------- ------------------------------------------------------------ ------------------------------------------------------------ 
    001        Robert Murphy                                                Adams                                                        
    002        Eric Craig                                                   Green                                                        
    003        Jennifer William H                                           Brown                                                        
    I need to come up with the first name and initial of the students.

    Any help is greatly appreciated!

    Thank you

    Published by: Roxyrollers on August 18, 2011 12:53

    Assuming that each name is exactly the same format

    SQL> ed
    Wrote file afiedt.buf
    
      1  select student_id,
      2         SUBSTR(student_name,
      3                INSTR(student_name,',')+1,
      4                LENGTH(student_name)-INSTR(student_name,' ')) first_name,
      5         SUBSTR(student_name,
      6                INSTR(student_name,' ')+1) middle_name,
      7         SUBSTR(student_name,
      8                INSTR(student_name,' ')+1,
      9                1) middle_initial,
     10         SUBSTR(student_name,1, INSTR(student_name,',')-1) last_name
     11* from   grad_student_tb
    SQL> /
    
    STU FIRST_NAME      MIDDLE_NAME          MIDDL LAST_NAME
    --- --------------- -------------------- ----- ---------------
    001 Robert          Murphy               M     Adams
    002 Eric            Craig                C     Green
    003 Jennifer        William H            W     Brown
    

    In general, of course, analysis names as it is much more complicated because you have to deal with the family as "la Hoya" names that contain spaces and cannot easily be distinguished from someone with several names.

    Justin

  • Have not used my email in a long time and I forgot the user name and password

    Hello. I don't use my thunderbird email in a long time and can't remember my user name or password if I remember my email address. How can I connect?

    Your user name is all or part of your e-mail address.
    The user name and the password is given with your email provider. You need to communicate with them.
    Most providers have a password reset link on their page for help by e-mail.

  • message: configuration cannot be verified - is the user name and password? None of them are wrong. I'm trying to set up my work email. How to solve the thi

    I have been using Thunderbird for a long time. One day he told me that my password is incorrect. After several attempts, the correct password decided to remove the e-mail account and start to charge. Now, when I put the account it says "configuration could not be verified - is the user name and password? None of them are wrong. I tried to change the password, contact my email provider and everything works fine except when trying to use Thunderbird. The email that I had tried to set up is at work. Any help in fixing this will really appreciate it.

    The best suggestion is to get the correct settings from your provider. They move to the top of their servers. They know the settings that work.

  • Options &gt; Security &gt; passwords saved and printed on the site, the user name and passwords saved on my computer, thank you.

    Options > Security > saved passwords, can I print on the site, the user name and passwords saved on my computer, or how to locate the file where this information is kept. I change computers and want to transfer the information to the new laptop. Thank you.

    See

  • Qosmio F55-Q502 cannot use GPS in the Viet Nam and Southeast Asia

    I have a Toshiba Qosmio F55 Q502 with purchase of system built-in GPS Garmin from the United States.
    But when I bring it to the Viet Nam and try to use the GPS, it does not work.

    I open Garmin Mobile PC, just Americans and Europeans of the cards.
    I try to activate the GPS, but the satellite always signal empty.

    I tried to go many places with view of clear skies but cound around ' nt captures the satellite signal.

    If this GPS is Globe Positioning system which means it can be used anywhere in the world.
    I do not know may be my GPS have the problem or the GPS is unusable in VietNam.

    My laptop just to buy a few days and I have not tried the GPS in US before.
    Can someone help me solve this problem?

    GPS should be worldwide.

    You can use a normal GPS for your car? Or as in the Nokia N95 GPS phone?

  • New ThinkPad T460p just arrived - the product name and serial number missing from the outside of the machine

    This page shows where the product name and serial number should supposed to be on my ThinkPad: https://support.lenovo.com/us/en/find-product-name?cid=EDM_2016_NA_US_PP_SUPPORT_V2&RRID=1014681098&...

    However, any of these are displayed on the outside of my machine anywhere.

    I happen to know the product name and serial number. I was able to find other ways - that is not the issue. As far as I know, these physical labels should have with the machine.

    Was it simply a mistake during Assembly, or Lenovo just stopped putting on these labels? If the first case, is there a way to ask Lenovo send me these labels? If the latter, Lenovo might consider updating the page linked above.

    Any inisight would be duly appreciated.

    Nicholas

    My T460p shows the T460p at the bottom right of the screen and the serial number and the code of the product under the battery. But the T460 is very dark on the corner of the screen, and Seraglio/product numbers appear on the very dark black label under the battery.

  • Windows Server 2008, the server process could not be started because the configured identity is incorrect. Check the user name and password.

    When I started and connect to the windows 2008 Server and when trying to open any folder I get the below error message:

    The server process could not be started because the configured identity is incorrect. Check the user name and password.

    Please give me your entries for this problem.

    Kind regards

    Shankar Kale

    Hi Shankar,

    The question you posted would be better suited in the TechNet Forums. See the link.
    Hope this information helps.
  • I gave a comuter the person who owned it died. How can I change the user name and password?

    A few months ago, I gave a comuter the person who owned it died. The window indicates Micrsoft Window XP Professional-HP. My problem is that I do not have access on behalf of users and password. What should I do?

    Hello

    Many on this forum suggests that when you "inherit" a PC, you should do a clean install of Windows to delete the unwanted "baggage" that the previous owner has left behind. For example (but not limited to) viruses and criminal and illegal downloads. Such a procedure will reset all the passwords anyway. The PC may have a factory reset mechanism still intact. Visit the manufacturer website for more information, or we do know the number of brand, range and model of your PC for assistance.

    If you are using XP Home Edition, the built-in Administrator account probably doesn't have a defined password. You can start in safe mode, where this account will be selectable when connecting. It allows to connect and change the password of any other connection.

    To start in safe mode, keep hitting F8 twice a second after turning on the PC until you get the start menu where safe mode is selectable by the up/down arrow keys, and then press ENTER.

    If you are using XP Professional, try to connect using the built-in Administrator account. You don't need to do it in safe mode (although you can if you wish). If your normal login screen is a display of the user symbol and hit ctrl-alt-del twice to get to login to text entry. Type administrator as the user name and try a blank password.

    See also http://support.microsoft.com/kb/321305

    Other than the foregoing, this forum has a policy of unknown passwords

    http://support.Microsoft.com/kb/189126

    Tricky

  • How can I remove the user name and the image of Windows XP new Start Menu

    Two questions:

    1. How can I delete the user name and the image of Windows XP new start; and

    2. my computer keeps asking me to press the F1 key to start Windows.  How to skip this part?

    Thank you.

    Hello

    The image of user account can be removed by disabling the Welcome screen. Or, by opting for the classic Windows theme. Follow the method described in this article, if you want to remove the user name and the picture in the Start Menu, without disabling the Welcome screen and Windows XP theme.

    For those who want to delete the user name and the image of user account from the Start Menu, in order to have a blue white Panel at the top, try this:

    Registry warning
    Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    How to back up and restore the registry in Windows
    http://support.Microsoft.com/kb/322756/

    Step 1:

    a. start Windows Explorer and go to this folder:
     
    C:\Documents and Settings\All Users\Application Data\Microsoft account images

    b. in this folder, rename the BMP file that corresponds to your user account.
     
    (For example, if your user name is Robert, rename Robert.bmp to old_Robert.bmp)

    c. then rename the following folder:

    C:\Documents and Settings\All Users\Application Data\Microsoft account Pictures\Default pictures
     
    to something else, for example,.
     
    C:\Documents and Settings\All Users\Application Data\Microsoft account Pictures\No_Default images.

    Step 2:
     
    To remove the user name, follow these steps

    a. Click Start, click "RUN" and type "regedit.exe" and navigate to this key:
     
    HKEY_CURRENT_USER-Software-Windows Microsoft\------CurrentVersion-policies-Explorer

    b. in the right pane, the value NoUserNameInStartMenu-value data 1.

    c. close Regedit.exe and restart Windows.

    You'll find yourself with a blue area at the top of the Start Menu.

    Regarding the pressing 'F1' to start Windows, you have made no changes or was there a system crash after which the problem started?

    You may need to change the boot sequence in the BIOS to the default settings. I recommend you contact your PC vendor for this.

    Warning of the BIOS:
    BIOS change / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

  • When you enter the user name and password in Windows Mail I get the following error: Server error: 0x800CCC90, error number: 0x800CCC92.

    Difficulties of username and password.

    In Windows Mail I suddenly wonder for the user name and password.  I fill them but receive no mail from mu.  I get the message:

    Account: 'pophost1.classicfm.net', server: 'pophost1.classicfm.net', Protocol: POP3, server response: '-ERR failed the connection. ', Port: 110, secure (SSL): no, Server error: 0x800CCC90, error number: 0x800CCC92.
    Please can you help me?

    Hello

    ·         Were there any changes to the computer, lately?

    Method 1:

    (a) start the Windows Messaging mail client.

    (b) click on 'Tools' from the main menu and choose "accounts".

    (c) a pop up will appear showing you all the email accounts in Windows Mail. Select the one that gives you the error and then click on the button 'Properties'.

    (d) another window pop up displays all parameters associated with this account.

    (e) under the "servers" tab check the 'e-mail username' and 'password'. One of them would certainly incorrect which translates the ID of Windows Mail error 0x800CCC92

    (f) to avoid having to enter the user name and password each time, check the box in front of "Remember password".

    (g) once you make the appropriate changes, click on the button 'apply' then 'OK'. Close the other pop-up window

    Method 2: Remove the existing from Windows mail email account and create a new one following the link provided below.

    http://Windows.Microsoft.com/en-us/Windows-Vista/add-or-remove-a-Windows-mail-account

    Reference:

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-Windows-Mail

  • In Windows Mail, journal on security keeps popping up asking me to check the user name and password.

    Original title: "Windows Security".

    I have Vista Home Premium with SP 2. In Windows Mail, logon security keeps popping up asking me to check the user name and password. This happens from time to time for many months and I've always got to work but happened several times today.  I can sign in the server through my ISP and get email. In Windows mail, I confirmed that the name of username-password is the same that I connect through the ISP.  I can't front/send by email but receive in Windows mail.

    Server response: '-ERR [IN USE] account is locked by another session or for maintenance, try again.',

    So wait a while and try again later.  You can also go to their website and log on there to see if it works.

    Also try to compact and repair the database (see www.oehelp.com/WMUtil/)

    Steve

  • I'm trying to restore the Vista system on a Dell computer. It restores to the point where I have to put in the user name and password, but it does not type in the username areas. Help. Thank you

    I use the recovery disks, restore the Visat OS on a dell laptop.  After the OS system, it displays the screen that requires the user name and password.  I can change the image associated with the user name, I can move the box around the screen, but it won't let me type in the username and password box.  Without putting the usernane and the password it will not go further, and I can not restore.  Help, please.  Thank you.

    Hello

    This is the Information from Dell to reinstall using disks:

    http://support.Dell.com/support/topics/global.aspx/support/KCS/document?c=us&CS=19&l=en&s=DHS&docid=DSN_339949&isLegacy=true

    For any problem using it, contact Dell:

    http://support.Dell.com/support/topics/global.aspx/support/DellCare/contact_technical_support

    Or post in the Support Forums:

    http://en.community.Dell.com/support-forums/default.aspx

    See you soon.

  • Everytime I open my Windows Live email account I asks me to enter the user name and password and I see an 0x8000CC17 error message

    Whenever I open my email account, I asks me to enter the user name and password and I see an 0x8000CC17 error message. Please can you offer any advice. Thank you

    * original title - Hello, I am a user of Windows Vista and my email account is windows mail *.

    Hi Petersanswers,

    Thanks for posting your question in the Microsoft answers Forum.  For information about Windows Live Mail, please visit the following link:

    http://windowslivehelp.com/forums.aspx?ProductID=15

    Thank you!

Maybe you are looking for