Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perfmon.exe未通过powershell显示网络接口的值_Powershell_Collections_Perfmon - Fatal编程技术网

Perfmon.exe未通过powershell显示网络接口的值

Perfmon.exe未通过powershell显示网络接口的值,powershell,collections,perfmon,Powershell,Collections,Perfmon,我一直在尝试让powershell在Windows 7的perfmon.exe中生成包含特定信息的csv文件 它大部分工作正常,但似乎忽略了3个计数器 脚本如下所示: $SampleInterval="4" $MaxSamples="15" $FileDestinationFolder="C:\Perfmon" $date = (Get-Date).ToShortDateString() Get-Counter $gc = ('\Network Interface(`*)\Current Ba

我一直在尝试让powershell在Windows 7的perfmon.exe中生成包含特定信息的csv文件

它大部分工作正常,但似乎忽略了3个计数器

脚本如下所示:

$SampleInterval="4"
$MaxSamples="15"
$FileDestinationFolder="C:\Perfmon"
$date = (Get-Date).ToShortDateString()
Get-Counter 
$gc = ('\Network Interface(`*)\Current Bandwith', 
        '\Network Interface(`*)\Packets Recieved/sec',
        '\Network Interface(`*)\Packets Sent/sec',
        '\PhysicalDisk(_Total)\Disk Write Bytes/sec',
        '\PhysicalDisk(_Total)\Disk Read Bytes/sec',
        '\Processor(_Total)\% Processor Time',
        '\Processor(_Total)\% Idle Time',
        '\Memory\% Committed Bytes In Use',  
        '\Memory\Available MBytes')
Get-Counter -counter $gc -SampleInterval $SampleInterval -MaxSamples $MaxSamples | export-counter -force -path ("$FileDestinationFolder\PerfMon-$date.csv") -FileFormat csv
我确实得到了物理磁盘、处理器和内存的统计数据,但没有任何网络接口。网络接口的路径是从数据采集器本身获取的。 你知道为什么会这样吗

编辑-- 如果我单独阅读它们,我可以看到它会打印Powershell ISE中的所有网络接口,但不会将内容写入csv文件

关于输出的示例是

时间戳反采样
------------------
06-12-2012 15:13:30\dkspare03\网络接口(英特尔[r]82577lm gigabi t网络连接)\n字节总数/秒:
271012080498825

目前,网络接口有一个转义字符,用于告诉要读取的NIC。 如果我没有,powershell将登记一个错误,如下所示:

$SampleInterval="4"
$MaxSamples="15"
$FileDestinationFolder="C:\Perfmon"
$date = (Get-Date).ToShortDateString()
Get-Counter 
$gc = ('\Network Interface(`*)\Current Bandwith', 
        '\Network Interface(`*)\Packets Recieved/sec',
        '\Network Interface(`*)\Packets Sent/sec',
        '\PhysicalDisk(_Total)\Disk Write Bytes/sec',
        '\PhysicalDisk(_Total)\Disk Read Bytes/sec',
        '\Processor(_Total)\% Processor Time',
        '\Processor(_Total)\% Idle Time',
        '\Memory\% Committed Bytes In Use',  
        '\Memory\Available MBytes')
Get-Counter -counter $gc -SampleInterval $SampleInterval -MaxSamples $MaxSamples | export-counter -force -path ("$FileDestinationFolder\PerfMon-$date.csv") -FileFormat csv
获取计数器:内部性能计数器API调用失败。错误:c0000bb9。 第38行字符:12
+获取计数器计数器似乎需要Powershell 3.0。对日期变量进行了编辑,以避免在命名文件和文件夹时产生进一步的问题。
此外,“Received”必须更改为“Received”。

在windows7上,您的代码正常工作,我刚刚更改了“$date=Get date-f'ddMMYYYY”,以避免文件创建中出现错误。您能在csv文件中看到网络信息吗?我认为正在发生的事情是,如果我包含all(使用*作为通配符),它就不能在一个字段中写入多行。因此,如果我不给每张卡片单独命名,我不知道它应该如何工作。问题是,此脚本要分发到多个不包含相同硬件的服务器。如果它适合你,你能贴一张它的照片或类似的照片吗?我个人也运行Windows7。这些问题也存在于2K8R2机器上。在安装了PowerShell 3的Windows 7上工作!我应该提到我使用的是2.0。我会立即更新它。如果我不在网络接口上使用通配符,而是声明特定接口,或者忽略该部分,不尝试将其打印到csv,那么一切都会正常进行