VMware Cloud Community
ms5812
Enthusiast
Enthusiast
Jump to solution

Trying to get ALUA, Multipath, Advanced TCP and NFS setting to export

This is one I'm sure you've heard before, my script worked yesterday but doesn't work today. The script part did but I wasn't able to get it to create a csv with all the data. Today I'm at the printout below. 3 days ago I upgraded the remote instance of PowerCLI from 4.1 to 6.3 update 1. The script did work after the upgrade.

I would like to have the Hostname appear 1st followed by the Multipath and then the advanced TCP and NFS info. Any help would really be appreciated

##Use the Below to select more than 1 Virtual Center to run the script against, backspace over the #

param(

[parameter(Mandatory = $true)]

[string[]]$vCenter

)

 

$esxHosts = Get-VMHost | Sort Name

foreach($esx in $esxHosts){

  

Write-Host "ALUA and Multipath"

$esxcli.storage.nmp.device.list($null)

Write-Host "Reading TCP and NFS Advanced Configuration Settings on $esx"

 

Get-VMHostAdvancedConfiguration -VMHost $esx -Name *Net.TcpipHeapSize,*Net.TcpipHeapMax,*NFS.HeartbeatMaxFailures,*NFS.HeartbeatFrequency,*NFS.HeartbeatTimeout,*NFS.MaxVolumes

Export-Csv ESX.csv -NoTypeInformation -UseCulture

Were I'm at right now"

te.jpg

Working last night but no output to csv

working.jpg

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ms5812
Enthusiast
Enthusiast
Jump to solution

After spending the day working on it some more (glutton for punishment) I've gotten to the point of getting the output ALMOST there but 4 items to resolve (and 1 wish list item)

1: Use of the $Creds automation ( for inclusion in all scripts after this one) wish list Smiley Happy

2: Datacenter to show in report name for audit reconciliation

3: Hostname to show in the csv,

4: I am getting the output of Name, Key, Values (only need Name and Values) on the Advanced TCP and NFS settings

5: Am unable to get the Description to export even though I am seeing it in the PowerCLI screen for  $esxcli.storage.nmp.psp.list()

###TCPandNFS_Settings---TESTING EVERYTHING TOGETHER

 

[CmdletBinding()]

param (

   [Parameter(Position = 0, Mandatory = $true)]

   [System.String]

   $VirtualCenterServer,

   [Parameter(Position = 1)]

   [System.String]

   $ClusterName,

   [Parameter(Position = 2)]

   [System.Boolean]

   $asLocalUser = $true

if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null)

 

   Add-PsSnapin VMware.VimAutomation.Core

if ($DefaultVIServers.name -ne $VirtualCenterServer)

 

   #Determine if we're logging in to VirtualCenter as a local user or if we should prompt for credentials

   if ($asLocalUser)

 

   Connect-VIServer -Server $VirtualCenterServer | Out-Null

   Write-Debug "Logging in as local user to vc: $VirtualCenterServer"

   else

   Connect-VIServer -Server $VirtualCenterServer -Credential (Get-Credential) | Out-Null

   Write-Debug "Logging in as manually selected user to vc: $VirtualCenterServer"

   Write-Host "Looks like we're already connected to: $VirtualCenterServer in this session"

if ($ClusterName)

 

   $VMHosts = Get-Cluster -Name $ClusterName | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" }

 

   $VMhosts = Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" }

 

$Report =

 

foreach($esx in (Get-VMHost))

 

  $esxcli = Get-EsxCli -VMHost $esx

   Write-Host "Reading TCP and NFS Advanced Configuration Settings on $esx"

(Get-VMHostAdvancedConfiguration -VMHost $esx -Name *Net.TcpipHeapSize,*Net.TcpipHeapMax,*NFS.HeartbeatMaxFailures,*NFS.HeartbeatFrequency,*NFS.HeartbeatTimeout,*NFS.MaxVolumes).GetEnumerator()

 

   # Select @{N='ESX';E={$esx.Name}}

   Write-Host "ALUA and Multipath Settings on $esx"

   $esxcli.storage.nmp.psp.list() 

  

$Report | Export-Csv "C:\Output.csv" -NoTypeInformation -UseCulture ; ii "C:\Output.csv"

pastedImage_1.png

Export when the $Report is commented out

pastedImage_2.png

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Looks like you don't initialise the $esxcli with a Get-EsxCli cmdlet.

That explains the error.

foreach($esx in (Get-VMHost | Sort-Object -Property Name)){

    Write-Host "ALUA and Multipath"

    $esxcli = Get-EsxCli -VMHost $esx

    $esxcli.storage.nmp.device.list() | Select @{N='ESX';E={$esx.Name}},Device,@{N='Paths';E={$_.WorkingPaths -join '|'}}

    Write-Host "Reading TCP and NFS Advanced Configuration Settings on $esx"

    (Get-VMHostAdvancedConfiguration -VMHost $esx -Name *Net.TcpipHeapSize,*Net.TcpipHeapMax,*NFS.HeartbeatMaxFailures,*NFS.HeartbeatFrequency,*NFS.HeartbeatTimeout,*NFS.MaxVolumes).GetEnumerator() |

    Select @{N='ESX';E={$esx.Name}},Name,Value

}

 

You can do the script as follows

But mixing different type of objects in a single CSV is impossible,

Do you really want all the data in one CSV ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ms5812
Enthusiast
Enthusiast
Jump to solution

Luc,

Thank you for the reply, as well as all of the video's you've done over the years, I'm slowly watching and making notes of them from your YouTube posts. I'm just a novice using PowerCLI compared to most here and have always used SSH and output it to a csv using a program similar to PuttyCommander that allows me to run against all the Hosts in a VC. I'm adding the input and output of what my ssh commands return below. This is what I'm needing to return in PowerCLI. I'm auditing over 3000 Hosts in 30+ VC's and ssh isn't an option with the security we have in place. As you can see I'm looking for my NetApp Filer setting that can cause issues if a Host fails without Multipathing set correctly and getting the low hanging fruit of TCP/NFS values at the same time. I've in the past output to 2 csv's and combined the outputs in excel, so 2 separate files is good.

Mark

esxcli storage nmp device list |grep -i VMW_PSP |grep -v VMW_PSP_RR ;esxcli storage nmp device list |grep -i VMW_SATP |grep -v VMW_SATP_ALUA;esxcli storage nmp device list |grep -i VMW_PSP |grep -v VMW_PSP_RR ;esxcli storage nmp device list |grep -i VMW_SATP |grep -v VMW_SATP_ALUA

pastedImage_1.png

esxcli storage nmp device list |grep -i VMW_PSP |grep -v VMW_PSP_RR && esxcfg-advcfg --get /NFS/HeartbeatFrequency && esxcfg-advcfg --get /NFS/HeartbeatMaxFailures && esxcfg-advcfg --get /NFS/HeartbeatTimeOut && esxcfg-advcfg --get /NFS/MaxVolumes &&  esxcfg-advcfg --get /Net/TcpIpHeapSize && esxcfg-advcfg --get /Net/TcpIpHeapMax

pastedImage_2.png

0 Kudos
ms5812
Enthusiast
Enthusiast
Jump to solution

After spending the day working on it some more (glutton for punishment) I've gotten to the point of getting the output ALMOST there but 4 items to resolve (and 1 wish list item)

1: Use of the $Creds automation ( for inclusion in all scripts after this one) wish list Smiley Happy

2: Datacenter to show in report name for audit reconciliation

3: Hostname to show in the csv,

4: I am getting the output of Name, Key, Values (only need Name and Values) on the Advanced TCP and NFS settings

5: Am unable to get the Description to export even though I am seeing it in the PowerCLI screen for  $esxcli.storage.nmp.psp.list()

###TCPandNFS_Settings---TESTING EVERYTHING TOGETHER

 

[CmdletBinding()]

param (

   [Parameter(Position = 0, Mandatory = $true)]

   [System.String]

   $VirtualCenterServer,

   [Parameter(Position = 1)]

   [System.String]

   $ClusterName,

   [Parameter(Position = 2)]

   [System.Boolean]

   $asLocalUser = $true

if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null)

 

   Add-PsSnapin VMware.VimAutomation.Core

if ($DefaultVIServers.name -ne $VirtualCenterServer)

 

   #Determine if we're logging in to VirtualCenter as a local user or if we should prompt for credentials

   if ($asLocalUser)

 

   Connect-VIServer -Server $VirtualCenterServer | Out-Null

   Write-Debug "Logging in as local user to vc: $VirtualCenterServer"

   else

   Connect-VIServer -Server $VirtualCenterServer -Credential (Get-Credential) | Out-Null

   Write-Debug "Logging in as manually selected user to vc: $VirtualCenterServer"

   Write-Host "Looks like we're already connected to: $VirtualCenterServer in this session"

if ($ClusterName)

 

   $VMHosts = Get-Cluster -Name $ClusterName | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" }

 

   $VMhosts = Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" }

 

$Report =

 

foreach($esx in (Get-VMHost))

 

  $esxcli = Get-EsxCli -VMHost $esx

   Write-Host "Reading TCP and NFS Advanced Configuration Settings on $esx"

(Get-VMHostAdvancedConfiguration -VMHost $esx -Name *Net.TcpipHeapSize,*Net.TcpipHeapMax,*NFS.HeartbeatMaxFailures,*NFS.HeartbeatFrequency,*NFS.HeartbeatTimeout,*NFS.MaxVolumes).GetEnumerator()

 

   # Select @{N='ESX';E={$esx.Name}}

   Write-Host "ALUA and Multipath Settings on $esx"

   $esxcli.storage.nmp.psp.list() 

  

$Report | Export-Csv "C:\Output.csv" -NoTypeInformation -UseCulture ; ii "C:\Output.csv"

pastedImage_1.png

Export when the $Report is commented out

pastedImage_2.png

0 Kudos