# PowerShell

PowerShell (opens new window) 是微软开发的跨平台任务自动化工具和脚本语言,结合了命令行 Shell 的交互性与脚本语言的灵活性。

# 一、Cmdlet

# 管道操作

# 版本信息

通过 $PSVersionTable (opens new window) 变量查询版本信息。

$PSVersionTable

# 执行策略

PowerShell 执行策略是一项安全功能,用于控制 PowerShell 加载配置文件和运行脚本的条件。

获取当前执行策略。

Get-ExecutionPolicy

更改执行策略。

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  • RemoteSigned

    脚本可以运行。

# 注册表操作

  • Set-ItemProperty (opens new window)

    创建和更改注册表值和数据。

    Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name IPEnableRouter -Value 1
    Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"