"Reporting if a NIC isn't running at 1Gbps"

Hi,

We are trying to develop a Script that will report to MaxRM Dashboard if a NIC isn't running at 1Gbps.
Currently I have a script that can report the Link Speed of a NIC - But I can't get an IF Statement working with this to report to MaxRM:

My Script with the IF Statement attached that isn't working is below

$adapter = Get-NetAdapter | Select-Object LinkSpeed

If ($adapter = "1Gbps")
{
Write-Host "1 Gbps"
$adapter
exit 2015
}
else
{
Write-Host "Less than 1Gbps!"
exit 0
}

Any help would be greatly appreciated

created 2 months ago
Press Start
 3 1 2
You must be signed in before you can post a fix
Scripting Language: PowerShell

Solution for Windows 7.
This also works in Windows 8 and above, but the other solutions are preferred for OS 8 and higher.


$adapters = Get-WmiObject -class win32_networkadapter -filter "NetConnectionStatus = 2"
$bAll1Gbps = $true

ForEach ($adapter in $adapters) {
    if ($adapter.Speed -ne 1000000000) {
        $bAll1Gbps = $false
    }
}

if ($bAll1Gbps) {
    Write-Host("All NICs are running on 1 Gbps")
    exit 0
} else {
    Write-Host("Not all NICs are running on 1 Gbps")
    exit 1001
}

created 2 months ago
Veronesi
 16 1 2

Comments:

Saviour! Thanks for your help today Press Start 2 months ago
cancel
Scripting Language: PowerShell

For several NICs try the following:


$adapters = Get-NetAdapter
$bAll1Gbps = $true

ForEach ($adapter in $adapters) {
    if (($adapter.Status -eq "Up") -and ($adapter.LinkSpeed -ne "1 Gbps")) {
        $bAll1Gbps = $false
    }
}

if ($bAll1Gbps) {
    Write-Host("All NICs are running on 1 Gbps")
    exit 0
} else {
    Write-Host("Not all NICs are running on 1 Gbps")
    exit 1001
}
created 2 months ago
Veronesi
 16 1 2

Comments:

Yeah that also works perfectly thank you .. Really appreciate your help so far, just the last question, would you be able to do the same for Windows 7? Press Start 2 months ago
cancel
Scripting Language: PowerShell

Try the following.
Hint: Get-NetAdapter is available on Windows 8.1 and upwards.


$adapter = Get-NetAdapter | Select-Object LinkSpeed
if ($adapter[0].LinkSpeed -eq "1 Gbps") {
    Write-Host("1 Gbps")
    exit 0
} else {
    Write-Host("Not 1 Gbps")
    exit 1001
}
created 2 months ago
Veronesi
 16 1 2

Comments:

Hi Veronesi, this is working perfectly, thank you - Is there a way to have it report on multiple NICs? for example if a server has 4 NICs? Also, is there another script for Windows 7 PCs please? Press Start 2 months ago
cancel

► Have questions?

► Something not working?

► Suggestions?

Post your questions on the meta site, where we discuss everything related to FixIT Scripts

visit meta now»