Formatting the output of a request of $ P

Hi everyone, I am currently working on how to format the scriot next so that I get column headers for the host name, vSwitch, Teddy bear, speed, duplex, status

For the moment he outpus format the data in a list, I can add to the script to get it in a table that I can use convertto-html on?

SE connect-VIServer

foreach ($esxImpl in (Get-VMHost)) {}

$esx = $esxImpl | Get-View

{foreach ($pnic to $esx.Config.Network.Pnic)}

$vSw = $esxImpl | Get-VirtualSwitch | where {$_.} {NIC-contains $pNic.Device}

$pg = $esxImpl | Get-VirtualPortGroup | where {$_.} {VirtualSwitchName - eq $vSw.Name}

$order = ($esx.Config.Network.Vswitch |) where {$_.} ({Name - eq $vSw.Name}). Spec.Policy.NicTeaming.NicOrder

$pnic | Select @{N = "ESXname"; {E = {$esxImpl.Name}}.

@{N = "Teddy"; E = {$pnic. Device}},

@{N = "vSwitch"; {E = {$vSw.Name}}.

@{N = 'Speed'; E = {$pnic. LinkSpeed.SpeedMb}},

@{N = "Duplex"; E = {$pnic. LinkSpeed.Duplex}},

@{N = 'Status'; E = {if($pnic.) (LinkSpeed-ne $null) {'up'} else {'down'}}}

}

}

I tried all kinds of things and I'm sure that when I see that the solution will understand where I was wrong

Thanks in advance for any help

Try with this method

Connect-VIServer 
$report = @()
foreach($esxImpl in (Get-VMHost)){
     $esx = $esxImpl | Get-View
     foreach($pnic in $esx.Config.Network.Pnic){
          $vSw = $esxImpl | Get-VirtualSwitch | where {$_.Nic -contains $pNic.Device}
          $pg = $esxImpl | Get-VirtualPortGroup | where {$_.VirtualSwitchName -eq $vSw.Name}
          $order = ($esx.Config.Network.Vswitch | where {$_.Name -eq $vSw.Name}).Spec.Policy.NicTeaming.NicOrder
          $pnic | %{
               $row = "" | Select ESXName, pNIC, VSwitch, Speed, Duplex, Status
               $row.ESXname = $esxImpl.Name
               $row.pNic = $pnic.Device
               $row.vSwitch = $vSw.Name
               $row.Speed = $pnic.LinkSpeed.SpeedMb
               $row.Duplex = $pnic.LinkSpeed.Duplex
               $row.Status = &{if($pnic.LinkSpeed -ne $null){"up"}else{"down"}}
               $report += $row
          }
     }
}
$report

You can run the table $report to another cmdlet Export-Csv or Convertto-Html command

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • Customize and format the output number

    How can I can format the output divided by a number?

    For example, the space time often displayed as bytes, I always manually to divide by 1024 ^ 3 to make it user-friendly.

    Example below...

    Get-Datastore. Get-View | Select summary - ExpandProperty | SELECT name, capacity, FreeSpace, @{N = 'Supplied'; E={ ($_. Capacity - $_. FreeSpace + $_. Not posted)}}

    OK, I see.

    You can use the same technique for the other 2 properties. Something like that

    Get-Datastore | Get-View |
    Select -ExpandProperty Summary |
    Select Name,
        @{N="Capacity"; E={[Math]::Round($_.Capacity/1GB,1) }},
        @{N="FreeSpace"; E={[Math]::Round(($_.FreeSpace/1GB,1) }},
        @{N="Provisioned"; E={[Math]::Round(($_.Capacity - $_.FreeSpace + $_.Uncommitted)/1GB,1) }}
    

    Another option is to use the New-VIProperty cmdlet and set these properties in the UK.

    Refer to the section of the data store in my New VIProperty module, where you will find the instructions to New-VIProperty to provide the properties CapacityGB, FreeGB , and ProvisionedGB .

  • How to format the output of a .sql script that has select statements.

    Hello

    I have a .sql script which is having several select statements. Each Select statement is to have hundreds of Table columns.

    When we run the .sql script, we are unable to read the output.

    Please let know us the commands that we include for better readable output format.

    You work with the lin standard set 80.
    Increase this setting to set lin 3000 or more.

  • help - match I want to write the output to a release

    I'm trying to write a script that connects to a vcenter server and search for a virtual machine with an ip address that is entered by the person running the script.  I've got it works fairly well except if I try to format the output (I want that he give me the name of the virtual machine when it finds the ip address or to tell me that he has not found a match) with an if / else statement I get no results when a match is found.  I don't know just where and how the 'match' information is kept so I can go back to the end user. If I just run $array - $match_address match it returns information, but with the formatting:

    If ($array - corresponds to $match_address)

    {Write-host "Match found $_"}

    He says just "Match Found."  Where / how to stored the game?

    I have attached the script to the aid station.

    Thank you.

    In $array you have a PSCustomObject admissions, where each has a property of intellectual property.

    You can find the match/nomatch like this

    #Connectez VIServer vct-00-ls

    #

    #$match_address = Read-Host "enter the ip address of the virtual machine to search."

    #

    # $array = get - VM | Select Name, @{N = 'IP address'; E = {@($_.guest.) IPAddress)}}

    # Specifies vCenter Server

    # #Prompt for the virtual center to connect to

    $vCenterName = Read-host "enter the name of the virtual center server you want to connect to.

    Password and user id # #Provide

    $vcentercred = get-Credential-Message "enter the user name and password to connect to $vCenterName"

    # #Connecting on the server vCenter/ESX

    write-host "connecting to vCenter Server $vCenterName" - green foreground

    SE connect-viserver $vCenterName - Credential $vcentercred

    Write-Host ""

    $match_address = Read-Host "enter the ip address of the virtual machine to search."

    $array = get-View - ViewType VirtualMachine. Select Name, @{N = "IP"; {E = {[string]: Join(',',$_.Guest.net.IPAddress)}}

    $vm = $array | where {$_.} IP-match $match_address}

    {if ($VM)}

    Write-Output "Match found $($vm.). (Name) ".

    }

    else {}

    Write-Output "no match found."

    }

    Write-Host 'Disconnect' from $VcenterName. ForegroundColor - Red

    Disconnect-VIServer $VcenterName - confirm: $False

  • You can search a pattern and format the result.

    Hello
    I seek a function that search sequences and formats the output 1-way.
    I tried to do this with regular expressions, but could not succeed.

    My look of entry (projects codes) like this: EL10000, E10010RR, E10020ER.

    Project codes get a different format in the new year:

    EL10000 becomes 10000L 009 or EL patternwise ~ becomes ~ L009 where ~ is a number (10)
    E ~ RR becomes ~ R009 where ~ is a number (10)
    E ~ ER becomes ~ SBC9 where ~ is a number (10)

    Is this possible with regexp_replace in 1 statement or just need I build a function?

    Thanks in advance
    Auke Quist

    There is probably a better way...

    with x as
    (select 'EL10000' proj from dual union all
     select 'E10010RR' from dual union all
     select 'E10020ER' from dual
    )
     -- End of Sample data
    select proj
         , case
             when proj like 'EL%'
             then  substr (proj, 3)||'L009'
             when proj like 'E%RR'
             then regexp_substr (proj, '[[:digit:]]+')||'R009'
             when proj like 'E%ER'
             then regexp_substr (proj, '[[:digit:]]+')||'SBC9'
          end new_proj
      from x
    
  • You cannot change the output type and format in the page requests system - PeopleSoft process

    Hi all

    When I navigate to the PeopleSoft process scheduler page and try to run a process I see the output type and format web and txt only. I am unable to change the output type and format. All formats and types of output are marked as active in the system settings page. I'm super user of the system as well. I have as well the role of Admin ProcessScheduler. I would like to know if someone has already faced similar problems.

    Thank you

    Vimal

    Run the following SQL query to your OPRID:

    SELECT A.CLASSID, PSPRCSPRFL A.OVRDOUTDEST, PSOPRDEFN B WHERE B.PRCSPRFLCLS = A.CLASSID AND B.OPRID = '';

    Make sure that OVRDOUTDEST = 1.

    If it's 0 then you have to fix your configuration profile of the process as follows:

    -Main menu > PeopleTools > Security > list permission > CLASSID research (white list) back to top query

    -Go to the process tab

    -Click on "process the profile permissions

    S ' ensure that 'substitute an output Destination' is checked. Click OK, and then save.

    This should solve your problem.

  • Changing the format of output for simultaneous Standard programs

    Hi gurus,

    Can someone let me know if we can change the output format of the simultaneous Standard program.

    I have a requirement where I need to change the output format of the program simultaneous to text in the PDF Format.

    Will be supported Oracle if we make this change in the Standard program to print output to PDF Format.

    Thanks in advance

    Yes it is possible to change the output format of Standard concurrent programs.

    for our needs.

    We changed the output format of simultaneous program 'Active users' text to PDF...

  • Question about the output format...

    I run this command:

    Get - vm | Select-Object - name of the property, Notes, VMhost, invited


    and the output of the powercli window, only gives me the name column and not others... If reverse the order he still gives me one time as the first property in the list. Now if I run the same command, but the export to CSV all columns show with their associated statistics.

    How is it that I can't output suitable for all the columns in the window powercli?

    I am running powercli worm 5.5 Rel 1 64-bit...


    Any suggestion would be greatly appreciated as im trying to learn powercli...



    Thank you!!!

    If some properties of container which is long, he pushes the other properties of the screen?

    Try like this, you see all the properties?

    Get - vm | Select-Object - property, Notes, VMhost, invited name | Format-List

  • Simultaneous report runs very slowly when the output format is 'XML' on IBM 6.1

    We have recently updated one of our test server database IBM AIX 5.3 to 6.1 operating system. We are witnessing a strange question in the execution time-out of simultaneous reports that have output in XML format (no server of publication and the Publisher). Whenever the output format is set to XML, the execution time seem to have increased very high than it used to be less than 5.3. A report to take 10 seconds which takes about 4 minutes to complete which is huge in comparison. Information about the version as below

    Oracle EBS 11.5.10

    Oracle 10.2.0.4.0 DB

    IBM AIX 6.1 OPERATING SYSTEM

    Oracle reports 6.0.8.28.0 (I know old enough)

    Provide expert advice.

    Thank you!

    All the

    We have solved the problem. I would like to share for the benefit of the readers of the community, if they are facing similar problems.

    The reason for the slowness of the report was due to lack of installation of the 'VIEW' option that is used when XML reports. Reports whose outputs are in format PDF, XML, HTML etc, Post Script, they all need a virtual display makes setup and configuration properties of config pointing to this server whenever settings are do. It could be a windows machine with X-Server running on it for display purposes or it could be services that are running on the same server for Unix/Linux applications where the application runs. We have installed VNC as X-Server that hosts services for virual (X) output for display on UNIX itself and have configured it in the reports configuration file. It seems to have solved the problem and the reports are run as expected (must faster!)

    Thank you

    Girish

  • Any way to customize the output of tag_eventfromdate to view a different date format?

    The {tag_eventfromdate} and {tag_eventtodate} out of the dates in the format DD-MMM-AA is not-very-nice. Is it possible to adjust the output format to something more human of the environment as 'November 22, 2014?

    In the live platform - only with javascript at the moment.

  • Show deprecated Formats in the output Module settings do not appear in my output option!

    Hello I am new using Adobe after effects CC 2014 and all guilds help I look for After Effects say replace your video output such as h.264 (MP4) on did I need to click on the checkbox called "Show obsolete Formats in the output Module Settings", BUT go does not appear on my options area. Only three options are in this section but nothing that calls it. Can anyone help me please with this problem?

    See this for an explanation of this change and for the workflow to recommend:

    using Adobe Media Encoder to create videos WMV, H.264 and MPEG-2 for After Effects

  • Request for help with the output of a script

    Hello

    I need assistance with the output of a script. I have a script that retrieves advanced config of the esx hosts in a cluster and exports to a txt file. Here is the script I use:

    $Decimals = 1

    $VCServers = @)

    $VMSummaries = @)

    $InputFile = "VCs.txt".

    1. Read the input file, loop of VCs

    Foreach ($VCname in Get-Content $InputFile) {$VCServers += $VCName}

    Foreach ($VCServer to $VCServers)

    {

    $VC = to connect-VIServer $VCServer

    $VMhosts = get-VMHost

    Foreach ($VMHost to $VMhosts)

    {

    Write-Progress "Collecting information in $VCServer" 'connecting to host $VMHost' - Id 0

    $VMSummary = "" | Select the host name, TCPIPHeapMax, TCPIPHeapSize, HeartbeatTimeout, HeartbeatFrequency, HeartbeatMaxFailures, MaxVolumes

    $VMSummary.HostName = $VMHost.Name

    $VMSummary.TCPIPHeapMax = (get-VMHostAdvancedConfiguration - VMHost ($VMhost) - name Net.TcpipHeapMax). Values

    $VMSummary.TCPIPHeapSize = (get-VMHostAdvancedConfiguration - VMHost ($VMhost) - name Net.TcpipHeapSize). Values

    $VMSummary.HeartbeatTimeout = (get-VMHostAdvancedConfiguration - VMHost ($VMhost) - name of NFS. HeartbeatTimeout). Values

    $VMSummary.HeartbeatFrequency = (get-VMHostAdvancedConfiguration - VMHost ($VMhost) - name of NFS. HeartbeatFrequency). Values

    $VMSummary.HeartbeatMaxFailures = (get-VMHostAdvancedConfiguration - VMHost ($VMhost) - name of NFS. HeartbeatMaxFailures). Values

    $VMSummary.MaxVolumes = (get-VMHostAdvancedConfiguration - VMHost ($VMhost) - name of NFS. MaxVolumes). Values

    $VMSummaries += $VMSummary

    }

    }

    $OutputFile = "AdvancedNFS.txt".

    $VMSummaries | Format-Table | Out-file $OutputFile

    This script runs without any problem and generates a text file that looks like this:

    TCPIPHeapMax TCPIPHeapSize HeartbeatTimeout HeartbeatFrequency HeartbeatMaxFailures MaxVolumes hostname

    -


    -


    -


    -


    -


    -


    -


    abcd1 abcd2 abcd3

    I am trying to output a csv file and run into a problem where each host values are not displayed correctly. I replaced the last 2 lines in the script as follows:

    $OutputFile = "AdvancedNFS.csv".

    $VMSummaries | Export-CSV $OutputFile

    My output looks like this:

    Host name

    TCPIPHeapMax

    TCPIPHeapSize

    HeartbeatTimeout

    HeartbeatFrequency

    HeartbeatMaxFailures

    MaxVolumes

    ABCD1

    System.Collections.Hashtable + ValueCollection

    System.Collections.Hashtable + ValueCollection

    System.Collections.Hashtable + ValueCollection

    System.Collections.Hashtable + ValueCollection

    System.Collections.Hashtable + ValueCollection

    System.Collections.Hashtable + ValueCollection

    What I am doing wrong?

    Thank you

    Alex

    Hello

    You can try changing your script like this:

    • -Replace "." "With values '-["'-']. "

    • -Optimize calls to Get-VMHostAdvancedConfiguration

    Your code will look like this:

    ...

    Write-Progress "Collecting information in $VCServer" 'connecting to host $VMHost' - Id 0

    $VMSummary = "" | Select the host name, TCPIPHeapMax, TCPIPHeapSize, HeartbeatTimeout, HeartbeatFrequency, HeartbeatMaxFailures, MaxVolumes

    $VMSummary.HostName = $VMHost.Name

    $VMHostAdvancedConfig = get-VMHostAdvancedConfiguration - VMHost $VMHost - name Net.TcpipHeapMax, Net.TcpipHeapSize, NFS. HeartbeatTimeout, NFS. HeartbeatFrequency, NFS. HeartbeatMaxFailures, NFS. MaxVolumes

    [$VMSummary.TCPIPHeapMax = $VMHostAdvancedConfig\["Net.TcpipHeapMax"\]

    [$VMSummary.TCPIPHeapSize = $VMHostAdvancedConfig\["Net.TcpipHeapSize"\]

    $VMSummary.HeartbeatTimeout = $VMHostAdvancedConfig\ ['NFS. HeartbeatTimeout '\] '.

    $VMSummary.HeartbeatFrequency = $VMHostAdvancedConfig\ ['NFS. HeartbeatFrequency '\] '.

    $VMSummary.HeartbeatMaxFailures = $VMHostAdvancedConfig\ ['NFS. HeartbeatMaxFailures '\] '.

    $VMSummary.MaxVolumes = $VMHostAdvancedConfig\ ['NFS. MaxVolumes '\] '.

    $VMSummaries += $VMSummary

    ...

    Kind regards

    Dimitar

  • change the format of output file

    Hi all

    Can someone help me how to change the output file I get after clicking on the button EXPORT space separated to Comma seperated.. ?

    When I click on EXPORT, the output file (.dat file) is generated in the folder Outbox. I want to change the format of the data in this file as described above.

    Ex: "Account 9556545 hasnaoui" should convert as "account, 9556545, hasnaoui.

    Thanks in advance!

    In the adapter, go to export action script. There is a variable called strDelimiter that defines the delimiter character. By default it is set to "" change it simply to «,»

  • API to view the output/log of the concurrent requests

    Hi all:

    I use EBS 11.5.10 (DB: 10r2)

    Is there an API I can call to view the output/log of a concurrent request?

    We have the APEX Oracle installed in the same database as our EBS and I am developing a report of the APEX, where user provide a competing request id and then click a button; then APEX calls some Oracle EBS API to extract the output/log for this id of the request file and open it in the browser automatically (assuming that / natural log of output is the text).

    Thank you!

    Kevin

    Hey Kevin,

    Here is an example of a sqlplus session:

    Set serveroutput on 10000;

    SQL > declare
    number of v_request_id;
    v_two_task varchar2 (256);
    v_gwyuid varchar2 (256);
    v_url varchar2 (1024);
    Start
    v_request_id: = 123456; (request identification number)
    Select profile_option_value
    in v_gwyuid
    of fnd_profile_options o, fnd_profile_option_values ov
    where profile_option_name = 'GWYUID. '
    and o.application_id = ov.application_id
    and o.profile_option_id = ov.profile_option_id;
    Select profile_option_value
    in v_two_task
    of fnd_profile_options o, fnd_profile_option_values ov
    where profile_option_name = 'TWO_TASK.
    and o.application_id = ov.application_id
    and o.profile_option_id = ov.profile_option_id;
    v_url: = fnd_webfile.get_url (file_type-online fnd_webfile.request_log, id-online v_request_id, gwyuid => v_gwyuid, two_task-online v_two_task, expire_time => 100);
    dbms_output.put_line (v_url);
    end;
    /

    http://appstierservername.yourcompany.com:8000/OA_CGI/FNDWRR.exe?temp_ID=12788080980 (number will appear here)

    PL/SQL procedure successfully completed.

    SQL >

    I hope this helps.

    Published by: DBA115102 on June 10, 2011 17:27

  • Request to format the SD memory card

    When I tried to record a video with my digital camera that uses a card of 4 GB Sandisk suddenly he says "memory full" as well as "there is no data".  I'm sure that it was not close to being complete but now when I insert and check it on the PC, it tells me "format until I can use it. I check the properties and it shows that it is fully used and there is evidence of used space as having 0 bytes.  Are there any way to recover my files (photos and videos) back?...

    Hi Tsubasa Kumo,

    You can see the article provided by SanDisk.

    Error message "you must format the disk in the drive."

    http://KB.SanDisk.com/app/answers/detail/A_ID/7933

    Reference:

    http://KB.SanDisk.com/app/answers/detail/A_ID/312

    Please post with the State of the question.

Maybe you are looking for

  • ESPN3 replays fail to load, but the events live OK. I tried to reinstall FF15, FF12, Flash plugin. Nothing works. In IE live and replays loading.

    The problem started 2 days ago, when ESPN3 replay events stopped loading. Reading seems to be loading but never finishes although the events live do not load. I was running FF15 with the latest version of the Flash plugin. I uninstalled and then rein

  • BAD AND DEFECTIVE PRODUCT.

    I bought a laptop Acer e-1531 n I suffer afterthe purchase of the Acer laptop. Your company's product is very badand defective and also services is very very bad. During the month ofpurchase of this product, it has been formatted by 6times and it is

  • Windows media player security update

    I can't upgrade to the windows media player security upgrade for my overdrive media player. I go to tools and hit the upgrade of security and nothing happens. Went to the online version to be upgraded and I do not see anything to upgrade for windows

  • Switch from one computer to another startup disk?

    If I remove my boot from my XP Pro 32 bit computer drive and put in my computer XP Pro 64-bit that is not any other hard drive installed, will be the second start (64 - bit) machine up?

  • RVS4000 selective loss of DNS queries

    Is there a configuration option or a known bug that would cause a selective RVS4000 or garble queries DNS coming on the LAN side by side WAN, yet allow HTTP, SSH and Ping through without problem?  I think I have very strong evidence that this problem