PowerShell Script to search the FC target

We have looked everywhere and can not find the correct commands to get what we are looking for.  I hope someone can help.

If you connect to vCenter and Goto Setup / storage / right click on a data store and click Properties.  Then click on manage paths.  Under Fibre Channel, there is a target: value.  How get us this value of PowerCLI?  Thank you very much for your help!

In the vSphere Client, you see the node and the Port WWN concatenated sets.

To get the same result, use this

$report = foreach($esx in (Get-VMHost | where{$_.PowerState -eq "PoweredOn"})){
    foreach($lun in (Get-ScsiLun -VmHost $esx -LunType disk)){
        Get-ScsiLunPath -ScsiLun $lun | `        Select @{N="Host";E={$esx.Name}},
            @{N="LUN";E={$lun.CanonicalName}},
            @{N="Target";E={
                "{0:x} {1:x}" -f ($_.Extensiondata.Transport.NodeworldwideName,
                                  $_.Extensiondata.Transport.PortworldwideName)
            }}
    }
}

$report | fl

Tags: VMware

Similar Questions

  • 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

  • PowerShell script to change the DNS entries for all hosts

    Ive tried many others which have been posted on the web and none work... Someone at - it a script to change the DNS entries on all hosts?

    OK, changed a few pieces my end, it worked but now it's... Try this (50% confident

     $dnsServers = ("192.168.111.3","192.168.111.4")
    
     Get-VMHost | Get-View | %{
        $ns = Get-View -Id $_.configManager.networkSystem
        $dns = $ns.networkConfig.dnsConfig
    
         $dns.Address = @()
         foreach($server in $dnsServers) {
           $dns.Address += $server
       }
       $ns.UpdateDnsConfig($dns)
     }
    

    If you found this information useful, please consider the allocation of points for correct or helpful.

    Alan Renouf

    http://Virtu-al.NET

  • PowerShell script to browse the root of an ESXI host?

    I am currently working on a project to automate the task to bring our standard up to STIG vmware environment.


    I was able to make the largest part of the task using PowerCLI and vSphereCLI scripts. Some patches require that you check the data to files like/etc/ssh/ssh_config... I tried to use the vifs.pl, but that does not allow you to browse directories host root. Also trying to research how to execute SSH via Powershell commands, but there is no free utlity. Is there another way to do this?

    Here is an example: under text difficulty: I need to be able to read the content of/etc/ssh/ssh_config to check if there is the "LOCAL so."

    Under rule: the SSH client must not send any environment variables on the server or send only those relating to the regional settings.

    STIG ID: GEN005529-ESXI5-708 rule ID: SV - 51085r1_rule Vuln ID: V-39269

    Severity: CAT II class: Unclass

    Discussion:
    Environment variables can be used to change the behavior of remote sessions and should be limited. Local environment variables specify the language, character set and other features change the operation of the software according to the preferences of the user.

    Documentable: No.

    Check the content:
    Deactivate the lock mode.
    Select the shell ESXi.
    < file > = / etc/ssh/ssh_config
    < Required_keyword > = AcceptEnv
    < Required_keyword_setpoint > = LOCAL
    Run the following commands:
    # grep AcceptEnv/etc/ssh/ssh_config

    If 'AcceptEnv' is not set to 'LOCAL' a finding.

    Reactivate the lock mode.

    Difficulty of text:
    Deactivate the lock mode.
    Select the shell ESXi.
    < file > = / etc/ssh/ssh_config
    < Required_keyword > = AcceptEnv
    < Required_keyword_setpoint > = LOCAL
    Run the following commands:
    # vi < file >

    Add/Modify the < required_keyword > or < required_keyword_setpoint > where/as necessary for 'LOCAL '.

    Reactivate the lock mode.

    IAB: IAB-000366
    SP NIST 800 - 53A: CM - 6.1 (iv)
    NIST 800-53 SP: CM - 6B

    There is the free PuTTY Suite, with the included plink.exe you can do a SSH session on the ESXi server.

    There are several examples on how to use plink.exe in this community.

  • 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

  • Looking for powershell script to view the path data store policy

    Basically, I'm looking for the equivalent of powershell with esxcfg-mpath-l.

    Any help would be appreciated.

    Try the attached script.

  • PowerShell script to see the paths

    Hello

    Need a simple script to check how many paths are available from each vhba. Also need to determine if there are paths dead reported.

    Output:

    vmhba1:

    Target: 2

    Features: 10

    Course: 9

    Way of death:

    vmhba1:C0:t0:l0 State of Lun target

    vmhba2:

    Target: 2

    Features: 10

    Trails: 10

    THX

    Would this be something like this do?

    foreach($esx in Get-VMHost){
      foreach($hba in (Get-VMHostHba -VMHost $esx -Type "FibreChannel")){
        $target = $hba.VMhost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter |
          where {$_.Adapter -eq $hba.Key} | %{$_.Target}
        $luns = Get-ScsiLun -Hba $hba -LunType "disk" -ErrorAction SilentlyCOntinue | Measure-Object | Select -ExpandProperty Count    $nrPaths = $target | %{$_.Lun.Count} | Measure-Object -Sum | select -ExpandProperty Sum    $hba | Select @{N="VMHost";E={$esx.Name}},@{N="HBA";E={$hba.Name}},    @{N="Target#";E={if($target -eq $null){0}else{@($target).Count}}},@{N="Device#";E={$luns}},@{N="Path#";E={$nrPaths}}
      }
    }
    
  • PowerShell script to update the bios of HP

    Before the upgrade to vsphere 5.0, iwanted upgrade of bios by the ILO of the hp dl 380 g6 hosts.

    Is this possible?

    You can use plink.exe to connect to the interface of the ILO and then run the commands.

    Damian has a nice example in changing HP c-Class Blades via ILO and PowerShell

  • PowerShell script to count the number of VM / file

    Hello

    As I'm not totally comfortable in powershell, I am just posting my question here as some of you can probably answer that in a blink of an eye.

    How can I get a count of the VM / file?

    Thanks in advance,

    Erik

    Hi Erik,

    You can get a number of VMs per folder with:

    Get-file | Select-Object @{N = 'File'; E={$_. Name}},@{N="number VM; E={($_| Get - VM | Measure - Object). County}}

    Best regards, Robert

  • The Scripts PowerShell Script to remove AD Logon

    I'm trying to create a PowerShell script to remove the scripts of connection for all users in the AD.

    I'm trying to create a PowerShell script to remove the scripts of connection for all users in the AD.

    Hello

    Your question is addressed in these forums of consumers.

    Please use the following to ask this question.

    Windows 8 IT Pro category:

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

    Concerning

  • PowerShell Script - Annotations to CSV

    Hello everyone!

    I need a liitle powershell script that does the following.

    Get all the VM and when "CustomAttribute" is set to 1, write the values such as CPU, RAM,... in a csv file.

    I tried like this:

    $VMExport = get - VM | Get-Annotation CustomAttribute - Export | Where-Object {$_.} {Value - eq 1}

    But now, I have only the value 1 in the Variable '$VMExport' and can not use it for more things.

    Can someone help me with this?

    The CustomFields is a hash table, you can access the values by using the key as the index.

    You will need to use a property calculated for this

    $VMExport = Get-VM | where {Get-Annotation -Entity $_ -CustomAttribute Export | Where-Object {$_.Value -eq 1 }} |
    Select Name,ProvisionedSpaceGB,MemoryMB,NumCpu,Description,   @{N="Custom Field";E={$_.CustomFields["CustomFieldName"]}}
    

    It retrieves the value of the custom field called 'CustomFieldName' and it appears under the "Custom Field" 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

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

  • Run the powershell script in Workflow VCO

    Hi guys,.

    I'm pretty new to VCO and I am facing difficulties to get what I want. For you, this will be a Basic... but here's my question:

    I have a WF that I use in the WFStubmachineprovisionning that can generate me a name of virtual machine based on the selection of the user while he asked for a virtual computer in the VRA.

    The VM provisionned name looks like this: W203PKLXXX and I need to replace the XXX with a number that is available on the network.

    To do this, I need to query the DNS to see if there is, if not, 002 001... And so on... until an available and I send the full name of the virtual machine to the WF Stubprovisionning.

    This my first try to interact between VCO and a Powershell script. I can run script PS on my host configured, but do not know how to send variables to the custom WF that generates the name of the script of PS and send the name of VM from the script of the PS to the next step.

    Can someone give me a sample of variable to manage? I can't find anything on the net

    Just to tell you that I managed.

    the PS has returned an XML object, not a string. I had to use the method getxml() javascript property, and parse the string to get the value I need

    I also had to blind correctly (getxml) entry and exit (PS)

    If needed I can send you a few screenshoot

Maybe you are looking for