我正在尝试将下面命令的输出合并到excel表中。
netsh advfirewall firewall show rule name = all | out-file .\rules.txt当前,上面命令的输出如下所示
Rule Name: Remote Assistance (PNRP-Out)
----------------------------------------------------------------------
Enabled: Yes
Direction: Out
Profiles: Domain,Private
Grouping: Remote Assistance
LocalIP: Any
RemoteIP: Any
Protocol: UDP
LocalPort: Any
RemotePort: Any
Edge traversal: No
Action: Allow我需要把这个放在excel文件中,比如
Rule Name Enabled Direction Profiles Grouping LocalIP RemoteIP Protocol RemotePort Edge Transversal Actions
Remote Assistance (PNRP-Out) Yes Out Domain,Private Remote Assistance Any Any UDP Any No Allow有没有办法这么做。这只能在粉末级v2上完成。不能导入其他模块。对于netsh命令输出的每条规则,都应该这样做。
提前谢谢你!
发布于 2016-12-07 02:29:11
您可以使用com对象获取规则并转换为csv (可以使用excel打开csv),如下所示:
$Rules=(New-object –comObject HNetCfg.FwPolicy2).rules
$Rules | export-csv test.csv -NoTypeInformationhttps://stackoverflow.com/questions/41005840
复制相似问题