Partilhar via


Quick adapter speed settings? Use PowerShell

If you are an adminitrator or technical document writer you have a need to check the network adapter speeds of multiple systems. Below is how to do that using powershell from your local system or perhaps a jump box in another domain.

Install PowerShell 2.0 if you don't already have it installed on your system.

Create a common folder where you can put your PowerShell files (Mine is D:\PowerShell). Create a text file"%nameoffile%.ps1" you can name it whatever you want it doesn't matter since you will be referencing it directly. (I do recommend naming it something descriptive, when you get hundreds of files they are easier to manage).

Open the text file and enter the following text:

## speed.msh

## Kill!

foreach ($strComputer in $Args)

{

            $adapters = get-wmiobject -query "Select MACAddress, Caption From Win32_NetworkAdapterConfiguration Where DatabasePath IS NOT NULL" -namespace "root\cimv2" -computername $strComputer

            foreach ($adapter in $adapters)

            {

                        $mac = $adapter.MACAddress

                        $adapterName = $adapter.Caption.substring(11)

                        $linkSpeedObj = get-wmiobject -query "Select NdisLinkSpeed From MSNdis_LinkSpeed Where InstanceName = '$adapterName'" -namespace "root\wmi" -computername $strComputer

                        $adapterObj = get-wmiobject -query "Select NetConnectionID From Win32_NetworkAdapter Where MACAddress = '$mac'" -namespace "root\cimv2" -computername $strComputer

                        $result = $strComputer.ToUpper() + ", " + $adapterObj.NetConnectionID + ", " + $linkSpeedObj.NdisLinkSpeed

                        write-host $result

            }

}

Open your PowerShell interface, after the window opens be sure to set you execution policy to unrestricted ("Set-ExecutionPolicy Unrestricted") then after reading the disclaimer select your option. [?] the help feature does provide useful information about remote execution exposures. After entering "Y" you will proceed to an unrestricted execution line.

Change the directory path to the the folder where you are keeping your files. In our case d:, then cd .\PowerShell, once you are in the directory you can start with the execution portion of the query.

The command has the ability to output more than just single server results. Just enter the file name then a "space" then the server name "space" server name, ect. . . see details below.

PS D:\PowerShell> %nameoffile%.ps1 %servername% %servername%

The output is simple and readable. If you have multiple network adapters it will output the names of each network adapter also. The output will look like "

"%Servername%, EFL, 1000000"