Dan*_*ach 22 powershell windows-server-2016
在哪里可以查看Windows Server 2016中所有会话的完整历史记录?
以下PowerShell命令仅包含当前会话中的命令:
Get-History
Run Code Online (Sandbox Code Playgroud)
Dan*_*ach 55
在PowerShell中输入以下命令:
(Get-PSReadlineOption).HistorySavePath
Run Code Online (Sandbox Code Playgroud)
这为您提供了保存所有历史记录的路径.然后在文本编辑器中打开路径.
尝试cat (Get-PSReadlineOption).HistorySavePath在PowerShell中列出历史记录.
小智 24
为了从 PowerShell 获取完整历史记录并将输出保存到文件中,我使用以下命令:
Get-Content (Get-PSReadlineOption).HistorySavePath > D:\PowerShellHistory.txt
Run Code Online (Sandbox Code Playgroud)
Cod*_*jay 15
在 Windows PowerShell 上
要进入会话,您可以使用
h或history
但要获取您使用的计算机中编写的所有命令
cat (Get-PSReadlineOption).HistorySavePath
小智 11
由于您使用的是 Windows,因此您还可以使用下面的命令来打开“记事本”。
notepad (Get-PSReadlineOption).HistorySavePath
Run Code Online (Sandbox Code Playgroud)
其中提到了 Windows Server/Enterprise 版本,但作为 Pro(标准零售版本)用户,HistorySavePath我也可以使用。我需要查看最近在较旧的会话中安装了哪些 python 软件包,并想在此处为在历史中寻找特定内容的人们添加答案。
# if you like file names and line numbers included in your output
Select-String "<search pattern>" (Get-PSReadlineOption).HistorySavePath
# if you Just want the text without any of the other information
Get-Content (Get-PSReadlineOption).HistorySavePath | Select-String "<search pattern>"
Run Code Online (Sandbox Code Playgroud)
就我而言,我跑了
Select-String 'pip install' (Get-PSReadlineOption).HistorySavePath
Run Code Online (Sandbox Code Playgroud)
这给了我一个从我之前的会话中运行的 pip install 命令列表
...
[Path/To/File]:10401:pip install dash
[Path/To/File]:10824:pip install -r .\requirements.txt
[Path/To/File]:11296:pip install flask-mysqldb
[Path/To/File]:11480:pip install Flask-Markdown
[Path/To/File]:11486:pip install pygments
[Path/To/File]:11487:pip install py-gfm
[Path/To/File]:11540:pip install bs4
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15615 次 |
| 最近记录: |