get-history的使用
得到输入到命令行的历史记录
get-history (4..10)得到输入的第四到第十条记录
invoke-history 2 重新执行输入的第二条记录
$a=get-history
foreach($i in $a)
{add-content c:/p.psl $i.commandLine}将输入的历史记录保存在C盘的p.psl文件中
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($x)
Remove-Variable x
注意:该命令是正确的;当你使用Remove-Variable cmdlet时,你只需指定变量名本身,不需要添加$。