0
我正在研究检查特定目录中的文件夹的脚本。例如,我第一次运行脚本,它会生成一个包含目录中文件夹的txt文件。powershell导出到文本文件
我需要脚本来在脚本再次运行时向先前创建的txt文件中添加找到的任何新目录。
有没有人有任何建议如何做到这一点?
这里是我到目前为止的代码:
$LogFolders = Get-ChildItem -Directory mydirectory ;
If (-Not (Test-Path -path "txtfilelocated"))
{
Add-Content txtfilelocated -Value $LogFolders
break;
}else{
$File = Get-Content "txtfilelocatedt"
$File | ForEach-Object {
$_ -match $LogFolders
}
}
$File
太谢谢你了!一切都在工作!谢谢! – user22401
@ user22401很高兴帮助! –