像这样的结果..。
全光>> RESULTS.TXT
查找“网络卡”
但是,这只捕获了第一行条目:
Network Card(s): 2 NIC(s) Installed.我真正想看到的是:
Network Card(s): 2 NIC(s) Installed.
[01]: VMware Accelerated AMD PCNet Adapter
Connection Name: Production
DHCP Enabled: No
IP address(es)
[01]: 1.1.1.1
[02]: VMware Accelerated AMD PCNet Adapter
Connection Name: Backup
DHCP Enabled: No
IP address(es)
[01]: 2.2.2.2不需要运行整个系统信息-我能捕获有关网卡的细节吗?
也曾试图通过PowerShell..。
& systeminfo.exe | & FIND.exe "Network Card"而且也没用..。:(
发布于 2014-03-27 22:18:32
如果像对我一样,Network Card(s):总是在systeminfo的输出中最后出现,那么下面的内容应该适用于您。
@echo off
set s=
for /f "delims=" %%a in ('systeminfo') do (
if defined s echo %%a
for /f %%b in ("%%a") do if "%%b"=="Network" echo %%a & set s=1
)当s到达Network Card(s)并输出所有内容时,将其设置为一个开关。
如果Network Card(s)部分没有最后出现,并且需要一种更明确的方法来获取网卡信息,并且您可以使用CSV格式的输出,那么这也应该有效(尽管可能过于复杂):
@echo off
setLocal enableDelayedExpansion
set c=0
for /f "delims=" %%a in ('systeminfo /FO CSV') do (
set line=%%a
set line=!line:,= !
if "!c!"=="0" for %%b in (!line!) do (
set /a c+=1
if "%%~b"=="Network Card(s)" echo %%~b
) else for %%c in (!line!) do (
set /a c-=1
if "!c!"=="0" echo %%~c
)
)发布于 2014-03-27 22:59:07
嗯,尽管我刚读到你想要摆脱PowerShell的评论,因为我让它起作用了,而且它转储了你的例子中的所有信息,我想我还是会把它发出去……:)
function Get-NetworkCards {
[cmdletbinding()]
param(
[parameter(Mandatory=$false)][string]$ComputerName = "LocalHost"
)
$adapterCfg = ( gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $ComputerName | Sort-Object Index )
$adapter = ( gwmi -Class Win32_NetworkAdapter -ComputerName $ComputerName | Sort-Object Index )
foreach ( $nic in $adapterCfg ) {
if( $nic.IPEnabled -eq $true ) {
foreach ( $settings in $adapter ) {
if( $settings.DeviceID -eq $nic.Index ) {
$curr = $settings
}
}
$props = [ordered]@{
Description = $nic.Description;
Connection = $curr.NetConnectionID;
DHCPEnabled = $nic.DHCPEnabled;
IPAddresses = $nic.IPAddress;
}
$Obj = New-Object PSObject -Property $props
$Obj
}
}
}
get-networkcards发布于 2014-03-27 22:20:14
你想做什么,在PowerShell - http://blogs.technet.com/b/heyscriptingguy/archive/2008/09/08/how-do-i-find-information-about-the-network-adapter-cards-on-my-computer.aspx里
引用他们的剧本:
Param($computer = "localhost")
function funline ($strIN)
{
$num = $strIN.length
for($i=1 ; $i -le $num ; $i++)
{ $funline = $funline + "=" }
Write-Host -ForegroundColor yellow $strIN
Write-Host -ForegroundColor darkYellow $funline
} #end funline
Write-Host -ForegroundColor cyan "Network adapter settings on $computer"
Get-WmiObject -Class win32_NetworkAdapterSetting `
-computername $computer |
Foreach-object `
{
If( ([wmi]$_.element).netconnectionstatus -eq 2)
{
funline("Adapter: $($_.setting)")
[wmi]$_.setting
[wmi]$_.element
} #end if
} #end foreachhttps://stackoverflow.com/questions/22700201
复制相似问题