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($_)
        }
  }
}

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

  • Need to powershell script to gather the host ESX Info network

    Hello

    I need two scripts powershell to collect two types of information about the ESX host network.

    1. information vNIC -& gt; information on the vmnic (physical ESX host network adapter) connected to vSwitches.

    vNIC | VSwitch model | | Trade | Speed | Status | | PCI slot Active/stand-by/not assigned

    (Example) output expected:

    vmnic0 | intel corporation 82XXXX gigabit ethernet controller | vSwitch0 | service console, vMotion | 1000mbps Full | up 01:01.00 | | Assets

    2. Portgroup information

    PortGroup | vNIC (s) with active / standby |  PCI slot of vNIC (s) with active / standby | Physical switch with port number

    Expected results (example):

    Service console | vmnic0 (a) : (s) | 01 vmnic1: 00. 00 (a) : 02:00. 00 (s) | abcd-123 [GigabitEthernet10/10] : xyzf-7890 [Gigabitethernet11/11]

    Please note if CDP is not active, then in the field of physical switch values can contain "CDP is not enabled"

    Thanks in advance!

    Noticed that the two threads under became a little mixed in the script.

    This is the script with the devIds with the indication of the active / standby.

    foreach($esxImpl in (Get-VMHost)){
         $esx = $esxImpl | Get-View
         $netSys = Get-View $esx.ConfigManager.NetworkSystem
         foreach($pg in $esx.Config.Network.Portgroup){
              $pNICStr = @()
              $pciStr = @()
              $cdpStr = @()
              foreach($a in $pg.ComputedPolicy.NicTeaming.NicOrder.ActiveNic){
                   if($a){
                        $pNICStr += ($a + "(a)")
                        $pciStr += ($esx.Config.Network.Pnic | where {$_.Device -eq $a} | %{$_.Pci + "(a)"})
                        $cdpInfo = $netSys.QueryNetworkHint($a)
                        $cdpStr += &{if($cdpInfo[0].connectedSwitchPort){$cdpInfo[0].connectedSwitchPort.devId + "(a)"}else{"CDP not configured(a)"}}
                   }
              }
              foreach($s in $pg.ComputedPolicy.NicTeaming.NicOrder.StandbyNic){
                   if($s){
                        $pNICStr += ($s + "(s)")
                        $pciStr += ($esx.Config.Network.Pnic | where {$_.Device -eq $s} | %{$_.Pci + "(s)"})
                        $cdpInfo = $netSys.QueryNetworkHint($s)
                        $cdpStr += &{if($cdpInfo[0].connectedSwitchPort){$cdpInfo[0].connectedSwitchPort.devId + "(s)"}else{"CDP not configured(s)"}}
                   }
              }
    
              $pg | Select @{N="ESXname";E={$esxImpl.Name}},
              @{N="Portgroup";E={$pg.Spec.Name}},
              @{N="VLANid";E={$pg.Spec.VlanId}},
              @{N="pNIC";E={$pNICStr}},
              @{N="PCI location";E={$pciStr}},
              @{N="Physical switch";E={$cdpStr}}
         }
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • 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 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

  • Need a powershell script to create a local user on esx given the esx server list box

    Hello

    I need a powershell script to create a local user on esx in a given list entry of esx servers through a csv spreadsheet. The script should ask me the user name and the password for the user name to be created on the given list of esx servers.

    Thanks in advance!

    Just noticed that there is a lack of vacuum after the - password parameter.

    It should be

    $userName = Read-Host "Username"
    $password = Read-Host "Password" -AsSecureString:$true
    Import-Csv "C:\vmhosts.csv" | %{
         Connect-VIServer -Server $_.Hostname -Credential (Get-Credential)
         New-VMHostAccount  -Id $userName -Password $password -UserAccount:$true -GrantShellAccess:$true -Confirm:$false
         Disconnect-VIServer -Confirm:$false
    }
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Need a powershell script to find the PID of VM in an ESX box

    Hello

    I need a powershell script to list out the PID of all virtual machines running in a box of ESX.

    The script should prompt for ESX box name and root password.

    Expected results:

    The virtual computer name.  NEST

    Thanks in advance!

    My mistake, the point (any character) is to eat the rest of the message.

    Try again with

    $mask = [regex]"vmid=(\d+)\s+([\w-]+)"
    

    He accepts what regex esteem alphabetic characters or the hyphen (-).

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Need a PowerShell script to...

    Hi, I need a PowerShell script to list all the virtual machine from the center of data-list for each virtual computer all drives and formats the disc and the disc type and a free column for comments.

    Move us the backup platforms and try to develop a plan of migration for all virtual machines

    See you soon

    Looks like you are using an older version of PowerCLI, the CapacityGB was introduced in one of the previous PowerCLI builds.

    Try to upgrade.

    If an upgrade is not possible, you can do

    Get-Datacenter -Name MyDC | Get-VM | Sort-Object -Property Name |Get-HardDisk | Select @{N="VM";E={$_.Parent.Name}},Name,@{N="CapacityGB";E={[int]($_.CapacityKB/1MB)}},@{N="Type";E={[string]::Join('/',($_.DiskType,$_.StorageFormat,$_.Persistence))}},@{N="Comment";E={' '*25}} |Export-Csv C:\HD-report.csv -NoTypeInformation -UseCulture
    

    It also sorts the VM on their Name property.

  • Need a powershell script to extract VM-&gt; IP-&gt;-&gt;-&gt; mapping vSwitch portgroup vNIC

    Hello

    I need a powershell script to extract the following information for all the VMS in vcenter.

    vm_name | ESX_name | Cluster_name | vm_IP_address | vNIC_name | PortGroup | vSwitch

    Please note that multiple virtual machines have several vNIC where vNIC is connected to various exchanges

    Here you go

    $report = @()
    Get-VM | %{
         $vm = $_
         $_ | Get-Vmguest | %{
              $guest = $_
              if($_.Nics){
                   $i = 0
                   $_.Nics | %{
                        $row = "" | Select Name, Powerstate, Host, Cluster, "IP address","Nic Name",Portgroup,vSwitch
                        $row.Name = $vm.Name
                        $row.Powerstate = $vm.PowerState
                        $row.Host = $vm.Host.Name
                        $row.Cluster = ($vm.Host | Get-Cluster).Name
                        $row."IP address" = $guest.IPAddress[$i]
                        $row."NIC Name" = $vm.NetworkAdapters[$i].Name
                        $row.Portgroup = $guest.Nics[$i].NetworkName
                        $row.vSwitch = (Get-VirtualPortGroup -Name $guest.Nics[$i].NetworkName -VM $vm).VirtualSwitchName
                        $report += $row
                        $i++
                   }
              }
              else{
                   $row = "" | Select Name, Host, Cluster, "IP addr","Nic Name",Portgroup,vSwitch
                   $row.Name = $vm.Name
                   $row.Powerstate = $vm.PowerState
                   $row.Host = $vm.Host
                   $row.Cluster = ($vm.Host | Get-Cluster).Name
                   $row."IP address" = "na"
                   $row."NIC Name" = "na"
                   $row.Portgroup = "na"
                   $row.vSwitch = "na"
                   $report += $row
    
              }
         }
    }
    $report
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Shell ESX or MS Powershell script to add permissions to the user host account

    I have this command "Add a user" ESX 3.5 service console...

    CD/usr/sbin /.

    adduser-l user-p password u 502

    You know the command to give this user 'Read only' "permissions" of the "ESX Server"?

    The attachment shows where the permissions of the user (in this case Akorri) have been added to the GUI of the VIC connected to the ESX host.

    Even better... You have a PowerShell Script to add users and permissions?

    Hello

    You must use a shell script to modify the etc/vmware/hostd/authorization.xml file. I have yet to see a powershell script that can make these changes for you, but you could check in PowerGUI.

    Best regards
    Edward L. Haletky
    VMware communities user moderator, VMware vExpert 2009
    ====
    Author of the book ' VMWare ESX Server in the enterprise: planning and securing virtualization servers, Copyright 2008 Pearson Education.
    Blue gears and SearchVMware Pro items - top of page links of security virtualization - Security Virtualization Round Table Podcast

  • Get-QADComputer fails if run PowerShell script through Orchestrator workflow

    I use the "Get-QADComputer" cmdlet in my .ps1 script that is supposed to run via Orchestrator.  I have several PowerShell scripts started by Orchestrator and run on a host windows without any problem.  For this script, I have these 2 commands and still error.  The script does not error when run locally.

    Add-PSSnapin Quest.ActiveRoles.ADManagement - ErrorAction SilentlyContinue

    $Computer = get-QADComputer-identity "server01" | where {$_.name - eq "server01"}

    In troubleshooting, I ran Get-PSSnapin and can see that the snap for AD is loaded successfully.  I tried Connect-QADService and who also gives the same error, although it works very well on place.

    I use vCO 5.1.1. device.   On the hosts Windows where are the scripts PowerShell, the AD snap is version 1.6.0.2683.

    Here is the error in the logs Orchestrator...

    PowerShellInvocationError: Errors found during execution of script

    System.Runtime.InteropServices.COMException (0x8007054B): the specified domain does not exist or could not be contacted.

    at Interop.ActiveDs.IADsOpenDSObject.OpenDSObject (String lpszUserName, String lpszPassword, String lpszDNName, Int32 lnReserved)

    to Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.AdsiDirectory.NativeBind (adsPath String, AuthenticationTypes bindFlags)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.AdsiDirectory.BindToObject (String dn)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.ConnectorFactory.Create (String serverName, user String, SecureString password, type of ConnectorType)

    to Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.ConnectionAwareCmdlet.EstablishConnection (ConnectionProperties connectionProperties)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.ConnectionAwareCmdlet.GetContainer)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.GetUserCmdlet.BeginProcessing)

    at System.Management.Automation.Cmdlet.DoBeginProcessing)

    at System.Management.Automation.CommandProcessorBase.DoBegin)

    (Name of the dynamic Script Module: invokeScript #14)

    Thanks for the info.  I use the workflow "Invoke an external script" to run many of my host admin PowerShell scripts.  It is easier for me to keep all .ps1 files in one place and not import them into Orchestrator.  The article prompted me to switch my connection to host basic Powershell to Kerberos.  To do this, I had to update /etc/krb5.conf on the device of the vCO.  I've referenced VMware KB2036986 to work around the problem "unable to get kdc for the Kingdom.  This issue was mainly because we couldn't have krb5 configured previously.

    Now, I got a different error during execution of the workflow after bouncing vCO.

    System.NullReferenceException: Object Reference not set to an instance of an object.

    Has pointed out me the need to first make the connection AD.  He has not worked before without Kerberos authentication.  Once I added these lines of code, Get-QADComputer finally worked without error!   Thanks for the help.

    $pass = ConvertTo-SecureString - AsPlainText-Force - String "password".

    Connect-QADService - "example.com\serviceaccount" ConnectionAccount - ConnectionPassword $pass

    $Computer = get-QADComputer-identity "server01" | where {$_.name - eq "server01"}

    Disconnect-QADService

  • PowerShell script for DR purposes

    Hey all, coming from a windows background that I tend use VI Client to all of my needs, but I'm trying to get in tune with the tools and scripts what better then to do with powershell. We are currently running VI 3.5 U5 and VC 4.0 U1. What we want to do is to use powershell to do a few steps from our DR plan. We would like to be able to break the snapmirror, sweep guests ESX DR, once all LUNS are present we want to then be able to run the powershell script and record all virtual machines of the Rd. and put back them online. I'm still looking since I found a few pieces of the puzzle, but I would appreciate greatly any input in this case.

    Thanks again.

    To locate the files all VMX or VMTX on data warehouses that are not registered and register them, take a look at the adventurers of the lost VMX.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Such a powershell script exist?

    Windows Server Standard 2012R2. I know not enough about powershell scripts to be dangerous. So I guess that its better to ask for help on this one. As you know, in the Windows backup program, the e-mail feature is depreciated on server 2012. However, I had no problem of customization of a powershell script that I found so that it sends an email when the nightly backup is completed successfully. Te was easy to do. In Manager tasks I just put the firing an event, with the event being backup Windows and a number of event 4 - which means backup completed successfully. In fact, it works very well for my clients.  But it is not the fault of my client. (of course!)

    Customers only the desire to receive an email if the backup is not successful. But the reasons for a backup failed are many which can generate any number of errors in the event log. Since I'm just not knowledgeable of powershell scripts, I hope someone can help me here, or at least direct me to where I can get help. Basically, I need a script powershell like this:

    Trigger is "the eventID 14 (completed backup operation).

    If eventID in the Microsoft-Windows-backup/OPerational log prior to the triggering event is not 4, while sendmail

    This above would of course, include my work already sendmail script. Is this possible? Maybe someone has already done? Any help would be appreciated.

    Hello

    For technical support, repost the question in the Windows Server Forum.

    https://social.technet.Microsoft.com/forums/WindowsServer/en-us/home

  • PowerShell script

    Hello

    Say I want to install the Microsoft Patches each month on a field with 50 + servers. I need a script that could give me the following,

    (i.) the availability of each server present in the field, while running the script.

    II.) he should list on the fixes that have been set up so far and this should be exported to excel.

    Servers are 2003 & 2008. Also, I'm not particularly on Powershell scripts. So anything that meets the objective would be really useful.

    Please help me with this.

    Thank you much in advance.

    René-coral. (* E-mail address is removed from the privacy *)

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

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

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

  • Newbie question - tide may run a remote PowerShell script or BAT file?

    My first post.  I am new to raz, but I've had experience with other planners.

    I have a PowerShell script that must be run on a remote computer.  All the script needs software is installed on this computer.

    In addition, I need the script runs under a service account.  Is it possible and if yes, how can I go about it?

    This work will be be launched manually whenever this is necessary.

    Sure. There are some screenshots. A variable one, I used for the location of the folder on the server of tide (not required but I use a lot of scripts). One for the command of tide itself. The last one is the script runs remotely on windows work. Let me know if they don't make sense.

Maybe you are looking for

  • A8-50/A5500: decommissioning of BONE in 4.4.2 to 4.2?

    Hello I've updated to KitKat and now I can no longer copy the data from the internal memory of the tablet to a USB key. Something that has worked well under Ice Cream Sandwich. So, I want to come back to ICS. I understand that it is the original oper

  • Microsoft Feeds Synchronization

    Microsoft Feeds Synchronization - I get this every 20 to 30 seconds.  Why this is happening and how can I get to stop.

  • I have deleted a project in hotmail and need to recover it.

    Please please help! It is not in the deleted folder and re-does not appear when I click on the option to recover email deleted.

  • JDE myFirstapp construction problems

    Hello, I have installed Blackberry JDE and started; http://developers.Sun.com/mobility/MIDP/articles/blackberrydev/#0 Somehow, I get the next; Building firstappC:\blackberry\bin\rapc.exe-Calme = import... name of code \lib\net_rim_api.jar = app1\firs

  • Changes to pages are not displayed when Site previewing in the browser

    I've made a few changes to a couple of pages, and when I saw Page in the browser, the changes appear but when I saw Site in the browser, the changes aren't there and the old page is displayed, even if some of the information on the original page has