-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkCard_Information.ps1
78 lines (73 loc) · 2.94 KB
/
NetworkCard_Information.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function global:_Pause($message)
{
#Check if script is running by Powershell ISE
if ($psISE)
{
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show("$message")
}
else
{
Write-Host "$message" -ForegroundColor Yellow
$x = $host.ui.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
}
function global:_TradENtoFR($string)
{
$string = $string -replace "True", "Oui"
$string = $string -replace "False", "Non"
return $string
}
function global:_Ipv4Only($ip)
{
return ($ip -split(" "))[0]
}
function global:_DateFR($date)
{
return $date = $date -replace "^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*", '$3/$2/$1 $4:$5:$6'
}
function global:_TradStatus($number)
{
switch($number) {
0 {"Déconnecté"}
1 {"Connexion en cours"}
2 {"Connecté"}
3 {"Déconnexion en cours"}
4 {"Carte désactivé"}
5 {"Matériel désactivé"}
6 {"Dysfonctionnement matériel"}
7 {"Média déconnecté"}
8 {"Authentification"}
9 {"Authentification réussie"}
10 {"Authentification échouée"}
11 {"Adresse invalide"}
12 {"Informations requises"}
default {"N/A"}
}
}
$ListNetworkAdapter = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object -FilterScript {$_.netconnectionid -ne $null}
ForEach ($NetworkAdapter in $ListNetworkAdapter) {
$NetworkAdapterConfiguration = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Select-Object -Index $NetworkAdapter.Index
$Result = [Ordered]@{
"Nom de la connexion" = ": $($NetworkAdapter.NetConnectionID)";
"Fabriquant" = ": $($NetworkAdapter.Manufacturer)";
"Modèle" = ": $($NetworkAdapter.Name)";
"Carte physique" =": $(_TradENtoFR($NetworkAdapter.PhysicalAdapter))";
"Etat de la connexion" = ": $(_TradStatus($NetworkAdapter.NetConnectionStatus))";
"Adresse MAC" = ": $($NetworkAdapter.MACAddress)";
"Type de connexion" = ": $($NetworkAdapter.AdapterType)";
"DHCP activé" = ": $(_TradENtoFR($NetworkAdapterConfiguration.DHCPEnabled))";
"Serveur DHCP" = ": $($NetworkAdapterConfiguration.DHCPServer)";
"Bail DHCP - Obtenu" = ": $(_DateFR($NetworkAdapterConfiguration.DHCPLeaseObtained))";
"Bail DHCP - Expiration" = ": $(_DateFR($NetworkAdapterConfiguration.DHCPLeaseExpires))";
"Adresse IP" = ": $(_Ipv4Only($NetworkAdapterConfiguration.IPAddress))";
"Masque" = ": $(_Ipv4Only($NetworkAdapterConfiguration.IPSubnet))";
"Passerelle" = ": $(_Ipv4Only($NetworkAdapterConfiguration.DefaultIPGateway))";
"Serveur DNS" = ": $($NetworkAdapterConfiguration.DNSServerSearchOrder)";
"Suffixe DNS recherché" = ": $($NetworkAdapterConfiguration.DNSDomainSuffixSearchOrder)";
"Nom DNS du PC" = ": $($NetworkAdapterConfiguration.DNSHostName)"
}
$Result.GetEnumerator() | Where-Object {$_.Value.Length -gt 2} | Format-table -HideTableHeaders -AutoSize
}
_Pause("Appuyez sur une touche pour quitter le script.")
if (-Not $psISE) {Exit-PSSession}