I'm running the below command to get the IPv4 address as part of a script and this particular command is taking between 30 sec to 60sec to complete on multiple customer machines.
This script is executing slow on 5 of 10 customer machines. Each of the 5 slow machines only has 1 network adapter plus the normal loopback. The first PS execution of each session is predominantly the slowest, however subsequent executions in the same session have been observed to be as slow as the first. All 10 machines are on the same network, same OS version build: Windows Server, version 20H2, Build: 10.0.19042.1889
How can I determine cause of the slow execution?
Get-NetIpAddress -InterfaceIndex (Get-NetAdapter | Where-Object status -eq up | Select-Object -ExpandProperty ifIndex) | Where-Object AddressFamily -eq 'IPv4' | Select-Object -ExpandProperty IPAddress
The Measure-Command results are as follows:
PS> Measure-Command {Get-NetAdapter}
Days : 0
Hours : 0
Minutes : 0
Seconds : 32
Milliseconds : 326
Ticks : 234237163
TotalDays : 5.05975694444444E-07
TotalHours : 1.21434166666667E-05
TotalMinutes : 0.561369041666667
TotalSeconds : 32.0437163
TotalMilliseconds : 32043.7163