I’m not sure Write-Progress is the right tool here. These steps should complete very quickly, and the progress indicator would just flash by. For example:
Write-Progress -Activity 'Configuring Network Adapter' -CurrentOperation 'Assigning IP and Subnet' -PercentComplete 0 $iface.enablestatic($ip,$subnet) Write-Progress -Activity 'Configuring Network Adapter' -CurrentOperation 'Configuring DNS Servers' -PercentComplete 25 $iface.setdnsserversearchorder($dns) Write-Progress -Activity 'Configuring Network Adapter' -CurrentOperation 'Assigning Default Gateway' -PercentComplete 50 $iface.setgateways($gate) Write-Progress -Activity 'Configuring Network Adapter' -CurrentOperation 'Configuring DNS registration' -PercentComplete 75 $iface.SetDynamicDNSRegistration(“FALSE”) Write-Progress -Activity 'Configuring Network Adapter' -Completed(On a side note, keep in mind that $iface might be an array, if you have multiple IP-enabled adapters on your system.)
Are you looking for something more like verbose output of the exact amount of time each operation took? For that, the code might look something like this:
$elapsed = Measure-Command { $iface.enablestatic($ip,$subnet) } Write-Verbose ('Time to assign IP / Subnet Mask: {0:F2}ms' -f $elapsed.TotalMilliseconds) # and so on
Thank you so much for the help! I believe I understand what you mean when you talk about multiple adapters being in use. I tried the write-progress lines that you showed and when run in ISE it asks me to supply values for the parameter “Status”.
Write-Progress : Cannot bind argument to parameter ‘Status’ because it is an empty string.
At C:\TCPSettings.ps1:53 char:15
+ Write-Progress <<<< -Activity ‘Configuring Network Adapter’ -Completed
+ CategoryInfo : InvalidData: (:) [Write-Progress], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.WriteProgressCommand
I have to use Write-Progress hence my push for it. I will also try the write-verbose though! Thank you again!