windows - Powershell Get-NetAdapterAdvancedProperty -
i trying run powershell command batch file test.bat. calling command python popen not test.bat.(i using test.bat validation)
powershell.exe (get-netadapteradvancedproperty -name "slot 1" -displayname "jumbo packet").displayvalue
same command works out second argument -displayname "jumbo packet" python , batch
error when use second argument below:
get-netadapteradvancedproperty : positional parameter cannot found accepts argument '1'. @ line:1 char:2 + (get-netadapteradvancedproperty -name slot 1 -displayname:jumbo packet).displayv ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidargument: (:) [get-netadapteradvancedprop erty], parameterbindingexception + fullyqualifiederrorid : positionalparameternotfound,get-netadapteradvanc edproperty
* if run same command powershell window expected result.
(get-netadapteradvancedproperty -name "slot 1" -displayname "jumbo packet").displayvalue
i new powershell.thanks
python code:
iface="slot 1" cmd= 'powershell.exe (get-netadapteradvancedproperty -name "'+ iface +'" -displayname "jumbo packet").displayvalue' conn.modules.os.popen(cmd).read()
brackets have special meaning in command. escape them caret. quotes may need escaping caret.
but why indirection. ps uses wmi. wmi available via com. python can com.
this vbscript pulling out nics. should able in language supports com (nearly all).
set objwmiservice = getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2") set colitems = objwmiservice.execquery("select * win32_networkadaptor") each objitem in colitems msgbox objitem.name next
Comments
Post a Comment