You can use this script to list all file under a directory. Don’t forget to change ” -Value ‘AYILDIRIMPC,C:\'” as you wish.
$Hostname = $env:computername
$path = 'C:\'
$file = 'ListFile.txt'
New-Item -path $path -Name $file -Value 'AYILDIRIMPC,C:\' -ItemType file -force
Get-Content "C:\ListFile.txt"|findstr "$Hostname"|%{ $_.Split(',')[1];} > C:\ListFile2.txt
$InfoServer = Get-Content "C:\ListFile2.txt"
echo "Started" > C:\List_"$Hostname".txt
foreach ($direct in $InfoServer)
{
tree /F /A "$direct" >> C:\List_"$Hostname".txt
Tagged In:
Operating Systems