// GetNetworkAdapters returns a list of network adapters
GetNetworkAdapters returns a list of network adapters
// GetNetworkAdapters returns a list of network adapters
func GetNetworkAdapters(name ...string) ([]NetAdapter, error) {
	con, err := wmi.NewStandardCimV2Connection()
	if err != nil {
		return nil, err
	}
	q := []wmi.Query{}
	if len(name) > 0 {
		for _, val := range name {
			q = append(q,
				&wmi.OrQuery{
					wmi.QueryFields{
						Key:   "Name",
						Value: val,
						Type:  wmi.Equals},
				})
		}
	}
	result, err := con.Gwmi(NetAdapterClass, []string{}, q)
	if err != nil {
		return []NetAdapter{}, err
	}
	adapters, err := result.Elements()
	if len(adapters) == 0 {
		return []NetAdapter{}, nil
	}
	ret := make([]NetAdapter, len(adapters))
	for index, adapter := range adapters {
		s := &NetAdapter{}
		if err := wmi.PopulateStruct(adapter, s); err != nil {
			return []NetAdapter{}, err
		}
		s.cimObject = adapter
		ret[index] = *s
	}
	return ret, nil
}
func GetNetworkAdapters ( name ... string ) ( [ ] NetAdapter , error ) { con , err := wmi . NewStandardCimV2Connection ( ) if err != nil { return nil , err } q := [ ] wmi . Query { } if len ( name ) > 0 { for _ , val := range name { q = append ( q , & wmi . OrQuery { wmi . QueryFields { Key : " " , Value : val , Type : wmi . Equals } , } ) } } result , err := con . Gwmi ( NetAdapterClass , [ ] string { } , q ) if err != nil { return [ ] NetAdapter { } , err } adapters , err := result . Elements ( ) if len ( adapters ) == 0 { return [ ] NetAdapter { } , nil } ret := make ( [ ] NetAdapter , len ( adapters ) ) for index , adapter := range adapters { s := & NetAdapter { } if err := wmi . PopulateStruct ( adapter , s ) ; err != nil { return [ ] NetAdapter { } , err } s . cimObject = adapter ret [ index ] = * s } return ret , nil }
GetNetworkAdapters returns a list of network adapters
GetNetworkAdapters returns a list of network adapters