hi,
I am trying to create a PS script which will loop through the folder and subfolder inside a dir and then get the folder name where there is no files or files which are older than 90 days. Below is the folder structure. Output should be VendorA or VendorB or VendorC. I tried using gci but did not work.
FTP
VendorA
folderA
folder D
folderB
Folder E
Folder F
Folder G
folderC
VendorB
folderA
folder D
folderB
Folder E
Folder F
Folder G
folderC
VendorC
folderA
folder D
folderB
Folder E
Folder F
Folder G
folderC
Here is the code that i wrote however want to have the output in csv file in tabular form - Name, Creation time.
Try something like this. Get all of the Folders, then you can use a calculated expression to do another Get-ChildItem with the folder path to get the files to get a count. Once you have all of the counts, then you can just use a simple where to find the empty folders.
If it’s a ton of files, there could be some better options like System.IO.Directory. The * is the extension, so you could just get a count of *.txt if wanted:
Thanks Rob and Postanote, this helped. Initially we were considering the folder with files older than 90 days, but now we only need folder that has no files in it. I was able to get this using the above code.