如何将powershell响应复制到命令?
我想用命令而不是手动复制powercfg/l的响应。但我不知道如何复制回复。因此,当我键入命令时,我希望将响应复制到我的剪贴板 例如: 如果我键入powercfg/l,这就是响应如何将powershell响应复制到命令?,powershell,Powershell,我想用命令而不是手动复制powercfg/l的响应。但我不知道如何复制回复。因此,当我键入命令时,我希望将响应复制到我的剪贴板 例如: 如果我键入powercfg/l,这就是响应 Existing Power Schemes (* Active) Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced) Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Existing Power Schemes (* Active)
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c (High performance)
Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a (Power saver)
我希望将
powercfg/l
的响应复制到我的剪贴板中,是否在powershell中执行此操作?您可以使用内置的windows命令clip.exe
或powershell的设置剪贴板
:
# Using clip.exe
powercfg /l | clip
# Using Set-Clipboard
powercfg /l | Set-Clipboard
您可以使用内置的windows命令
clip.exe
或PowerShell的设置剪贴板
:
# Using clip.exe
powercfg /l | clip
# Using Set-Clipboard
powercfg /l | Set-Clipboard
这个更冗长,但它检索一个PSObject,而不仅仅是文本:
function Get-PowerSchemes
{
Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\ |
Where { Get-ChildItem -Path $_.PSPath } |
Select @{Label="Guid";Expression={ $_.PSChildName }},
@{Label="FriendlyName";Expression={ ((Get-ItemProperty -Path $_.PSPath -Name FriendlyName).FriendlyName -split ',')[2] }},
@{Label="IsActive";Expression={ $_.PSChildName -eq (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\ -Name ActivePowerScheme).ActivePowerScheme }}
}
Get-PowerSchemes | Set-Clipboard
例如,您可以轻松检索活动方案
Get-PowerSchemes | Where IsActive | Set-Clipboard
甚至只有他的指导
(Get-PowerSchemes | Where IsActive).Guid | Set-Clipboard
这个更冗长,但它检索一个PSObject,而不仅仅是文本:
function Get-PowerSchemes
{
Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\ |
Where { Get-ChildItem -Path $_.PSPath } |
Select @{Label="Guid";Expression={ $_.PSChildName }},
@{Label="FriendlyName";Expression={ ((Get-ItemProperty -Path $_.PSPath -Name FriendlyName).FriendlyName -split ',')[2] }},
@{Label="IsActive";Expression={ $_.PSChildName -eq (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\ -Name ActivePowerScheme).ActivePowerScheme }}
}
Get-PowerSchemes | Set-Clipboard
例如,您可以轻松检索活动方案
Get-PowerSchemes | Where IsActive | Set-Clipboard
甚至只有他的指导
(Get-PowerSchemes | Where IsActive).Guid | Set-Clipboard
powercfg/l | clip
或powercfg/l | set clipboard
powercfg/l | clip
或powercfg/l | set clipboard
。非常感谢您提供的信息,希望您最好。非常感谢您提供的信息,希望您做到最好