2014-09-25 113 views
0

Out-File允许我们将输出写入文件。如果我们想要将输入写入文件会怎么样?将命令(即输入不输出)写入文件

我想要在PowerShell会话期间编写的所有命令的列表。该文件应该是这样的:

dir 
cd 
ni myFile.txt -t file 
cd.. 

我们想跟踪我们在PowerShell中使用的命令。

回答

2

试试这个:

Get-History | 
select -ExpandProperty commandline | 
Add-Content commandhistory.txt 
1

你可以利用Start-TranscriptStop-Transcript

有关每个命令的Technet链接:start-transcriptstop-transcript

用例:Start-Transcript -Path C:\Folder\Transcript.txt