AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 408022
Accepted
Mike Pennington
Mike Pennington
Asked: 2012-07-16 21:20:14 +0800 CST2012-07-16 21:20:14 +0800 CST 2012-07-16 21:20:14 +0800 CST

使用 netsh 记录 Windows 连接

  • 772

我正在尝试netsh在 Vista x64 上启用连接日志记录,如这篇关于防火墙故障排除的 MSDN 文章所示......

首先,我启用了允许连接的日志记录%systemroot%\system32\LogFiles\Firewall\pfirewall.log,下面...

PS C:\Windows\system32> netsh advfirewall set allprofiles logging allowedconnections enable
Ok.

PS C:\Windows\system32>

接下来我检查是否真的启用了日志记录。AFAICT,这是...

PS C:\Windows\system32> netsh advfirewall show currentprofile

Public Profile Settings:
----------------------------------------------------------------------
State                                 ON
Firewall Policy                       BlockInbound,AllowOutbound
LocalFirewallRules                    N/A (GPO-store only)
LocalConSecRules                      N/A (GPO-store only)
InboundUserNotification               Enable
RemoteManagement                      Disable
UnicastResponseToMulticast            Enable

Logging:
LogAllowedConnections                 Enable
LogDroppedConnections                 Disable
FileName                              %systemroot%\system32\LogFiles\Firewall\pfirewall.log
MaxFileSize                           4096

Ok.

PS C:\Windows\system32>

但是,当我尝试检索日志时,我无法...

PS C:\Windows\system32> Get-Content %systemroot%\system32\LogFiles\Firewall\pfirewall.log
Get-Content : Cannot find path 'C:\Windows\system32\%systemroot%\system32\LogFiles\Firewall\pfi
oes not exist.
At line:1 char:12
+ Get-Content <<<<  %systemroot%\system32\LogFiles\Firewall\pfirewall.log
    + CategoryInfo          : ObjectNotFound: (C:\Windows\syst...l\pfirewall.log:String) [Get-C
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
PS C:\Windows\system32>

我还需要做什么才能从 powershell 启用连接日志记录?如果可能的话,我想避免重启。

windows firewall logging powershell
  • 1 1 个回答
  • 3580 Views

1 个回答

  • Voted
  1. Best Answer
    MichelZ
    2012-07-17T00:38:59+08:002012-07-17T00:38:59+08:00

    如您所见,%systemroot%当您检索日志文件时,您的变量在 PowerShell 中没有得到正确解析:找不到路径 'C:\Windows\system32\%systemroot%\system32\LogFiles\Firewall\pfioes 不存在。

    在 PowerShell 中,您可以通过以下方式访问环境变量:$env:Variable

    请试试这个命令:

    Get-Content $env:systemroot\system32\LogFiles\Firewall\pfirewall.log

    • 1

相关问题

  • 知道任何适用于 Windows 的快速可编写脚本的 ftp 客户端吗?[关闭]

  • 如果 Windows 服务崩溃,如何自动重新启动它?

  • 无法安排任务(访问被拒绝)

  • 物理机重启时自动重启虚拟机(VMWare)

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve