API Reference¶
NIC Instance Attributes¶
Refer to Microsoft Developer Network’s pages on the Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration classes for further information about the attributes listed below.
NIC Instance Attribute | Windows Class and Property | Python Type | Access |
---|---|---|---|
adapter_type | Win32_NetworkAdapter.AdapterType | NicAdapterType | Get |
availability | Win32_NetworkAdapter.Availability | NicAvailability | Get |
caption | Win32_NetworkAdapter.Caption | str | Get |
config_manager_error_code | Win32_NetworkAdapter.ConfigManagerErrorCode | NicConfigManagerErrorCode | Get |
config_manager_user_config | Win32_NetworkAdapter.ConfigManagerUserConfig | bool | Get |
description | Win32_NetworkAdapter.Description | str | Get |
device_id | Win32_NetworkAdapter.DeviceID | str | Get |
enabled_ctrl_panel | Custom Attribute (Is NIC Enabled in Control Panel?) | bool | Get |
error_cleared | Win32_NetworkAdapter.ErrorCleared | bool | Get |
error_description | Win32_NetworkAdapter.ErrorDescription | str | Get |
guid | Win32_NetworkAdapter.GUID | str | Get |
index | Win32_NetworkAdapter.Index | int | Get |
installed | Win32_NetworkAdapter.Installed | bool | Get |
interface_index | Win32_NetworkAdapter.InterfaceIndex | int | Get |
ip_addresses | Win32_NetworkAdapterConfiguration.IPAddress | list of str | Get |
last_error_code | Win32_NetworkAdapter.LastErrorCode | int | Get |
mac_address | Win32_NetworkAdapter.MACAddress | str | Get |
manufacturer | Win32_NetworkAdapter.Manufacturer | str | Get |
name | Win32_NetworkAdapter.Name | str | Get |
net_connection_id | Win32_NetworkAdapter.NetConnectionID | str | Get |
net_connection_status | Win32_NetworkAdapter.NetConnectionStatus | NicNetConnectionStatus | Get |
physical_adapter | Win32_NetworkAdapter.PhysicalAdapter | bool | Get |
pnp_device_id | Win32_NetworkAdapter.PNPDeviceID | str | Get |
power_management_supported | Win32_NetworkAdapter.PowerManagementSupported | bool | Get |
product_name | Win32_NetworkAdapter.ProductName | str | Get |
service_name | Win32_NetworkAdapter.ServiceName | str | Get |
speed | Win32_NetworkAdapter.Speed | int | Get |
NIC Instance Methods¶
Refer to Microsoft Developer Network’s pages on the Win32_NetworkAdapter and Win32_NetworkAdapterConfiguration classes for further information about the methods listed below.
NIC Instance Method | Windows Class and Method | Admin Access Required? | Parameters (In Order) | Returns |
---|---|---|---|---|
add_dns_server | Custom netsh Method (Add DNS Server Entry) | Yes | dns_server (str): DNS Server Address | Return Status Code (int) |
disable | Win32_NetworkAdapter.Disable | Yes | None | Windows Error Code (int) |
enable | Win32_NetworkAdapter.Enable | Yes | None | Windows Error Code (int) |
set_static_address | Custom netsh Method (Set Static IP Address Configuration) | Yes | ip_addr (str): Static IP Address subnet_mask (str): Static Subnet Mask gateway (str): Static Default Gateway |
Return Status Code (int) |
use_dhcp | Custom netsh Method (Use DHCP to Obtain IP Address) | Yes | None | Return Status Code (int) |
Tip
Decode a Windows error code by running net helpmsg #
, where #
is the
integer return value.
Tip
When using a method requiring administrative privileges, run the script from an administrative command prompt by navigating to a command prompt shortcut, right clicking it, and choosing “Run as administrator” from the menu.