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很高興幫助! –