我有 powershell 脚本。通过调度程序,我运行 bat 文件,该文件运行 PS1 文件。
BAT文件
Powershell.exe -executionpolicy remotesigned -File script.PS1
PS1 文件
$path = "D:\data";
$limit = (Get-Date).AddHours(-3);
Get-ChildItem -Path $path -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force;
在同一目录中,powershell 创建格式为 YYYYMMDD 的目录,其中包含文件 PowerShell_transcript.SERVER.t7eh07Gy.20230914031500.txt。这是整个脚本的运行过程。
例如: D:\data\20230914\PowerShell_transcript.SERVER.t7eh07Gy.20230914031500.txt D:\data\20230915\PowerShell_transcript.SERVER.t7eh07Gy.20230914031500.txt 等等
如何禁用它?
我尝试过停止转录等。
我需要停止转录。
最佳答案
转录的开始可以由组策略确定并独立于脚本执行。请查看此处的政策示例:
HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription
如果此键中有 EnableTranscripting 值且不等于 0,则启用转录。
关于Powershell 脚本 - 脚本 - 我如何禁用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77112562/