I'm hoping someone could tell what's wrong in this expression. I have less/no experience in scripting. I ran this script from vmware powercli and I connected to vcenter.
This is to set the configured speed(mentioned in the screen shot) of a physical nic of an ESX host to auto negotiate, which is currently set to 10000 MB.
physical nic : vmnic0
configured speed to be set: auto negotiate
VMhost name value is changed to xyz here.
I have 80 more hosts for which the vmnic values are to be set to autonegotiate as per the recommended settings. 4 nics are present for each ESX host. Totally I have to modify 320 times in order to perform this manually and get this fixed. Can someone help me with a script
PS C:\Windows\system32> Set-VMHostNetworkAdapter -vmhost xyz.contoso.net -PhysicalNic vmnic0 -AutoNegotiate
Result:
Set-VMHostNetworkAdapter : Cannot bind parameter 'PhysicalNic'. Cannot convert the "vmnic0" value of type "System.String" to type
"VMware.VimAutomation.ViCore.Types.V1.Host.Networking.Nic.PhysicalNic".
At line:1 char:80
+ ... -vmhost xyz.contoso.net -PhysicalNic vmnic0 -AutoNe ...
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-VMHostNetworkAdapter], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostNetworkAdapt
er
The Set-VMHostNetworkAdapter cmdlet expects a PhysicalNic object, not a string.
The easiest way is to first do a Get-VMHostNetworkAdapter and then place the returned object in the pipeline.
The PhysicalNic parameter can take the value from the pipeline.
Set-VMHostNetworkAdapter -AutoNegotiate
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The Set-VMHostNetworkAdapter cmdlet expects a PhysicalNic object, not a string.
The easiest way is to first do a Get-VMHostNetworkAdapter and then place the returned object in the pipeline.
The PhysicalNic parameter can take the value from the pipeline.
Set-VMHostNetworkAdapter -AutoNegotiate
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I ran the command and got this error again.
PS C:\Windows\system32> Get-VMHostNetworkAdapter -vmhost xyz.contoso.net -PhysicalNic vmnic0 |
Set-VMHostNetworkAdapter -AutoNegotiate
Result:
Get-VMHostNetworkAdapter : A parameter cannot be found that matches parameter name 'PhysicalNic'.
At line:1 char:67
+ ... Adapter -vmhost xyz.contoso.net -PhysicalNic vmnic0 ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-VMHostNetworkAdapter], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVMHostNetworkAdapter
My bad, I corrected the code above.
Try with that one
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It worked. Thank you so much. Is it possible to change this for all the 4 nics at once per host?
vmnic0
vmnic1
vmnic2
vmnic3
I myself tried that one. And it worked.
Get-VMHostNetworkAdapter -VMHost xyz.contoso.net -Name vmnic2,vmnic3 -Physical |
Set-VMHostNetworkAdapter -AutoNegotiate
But its asking for a confirmation for each Nic. So I have to give "Yes" each time. Is it possible to confirm it through script?
If you want to configure all pNIC on an ESXi node like this, just leave out the Name parameter.
To avoid the confirmation prompt, add the Confirm parameter and assign the $false value.
Set-VMHostNetworkAdapter -AutoNegotiate -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you so much
Is there any specific book suggestion you have to master this powercli commands? If yes please let me know, I wish to learn and write script myself.
There are several listed on Google when you search for PowerCLI books.
Some are basic/introductory, some are more advanced.
I like the roadmaps presented in
- PowerShell study guide – core concepts
- PowerCLI study guide – core concepts
They are free, comprehensive, and give you a good starting point.
And they have some book recommendations.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is it possible to get the adapter firmware device name details for all the hosts in vc?
Try something like this
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
ForEach-Object -Process {
$esxcli.network.nic.get.Invoke(@{nicname="$($_.Name)"}) |
Select @{N='VMHost';E={$esx.Name}},Name,
@{N='Driver';E={$_.DriverInfo.Driver}},
@{N='Version';E={$_.DriverInfo.Version}},
@{N='FirmwareVersion';E={$_.DriverInfo.FirmwareVersion}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This only gives the driver version of the FC & network. I need the firmware device name & version of physical adapters, which is like this
Lenovo Flex System FC3172 2-Port 8Gb FC Adapter - FC adapter name - version - 8.03.00
& Flex System CN4054 10Gb Virtual Fabric Adapter - Network adapter name. - version - 11.2.1193.76
Is it possible to fetch those details through script?
Try like this
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
ForEach-Object -Process {
$nic = $_
$esxcli.network.nic.get.Invoke(@{nicname="$($nic.Name)"}) |
Select @{N='VMHost';E={$esx.Name}},Name,
@{N='Description';E={$nic.Description}},
@{N='Driver';E={$_.DriverInfo.Driver}},
@{N='Version';E={$_.DriverInfo.Version}},
@{N='FirmwareVersion';E={$_.DriverInfo.FirmwareVersion}}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I wouldn't know.
You could give the As Built Report module a try.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference