I`m a beginner PowerShell user.
I need a powershell script. It must do:
In
\\routefolders\xxxxx
\\routefolders\jhon
\\routefolders\mike
\\routefolders\sandra
.
.
.
etc...
find files newer than 2 years
if exist some file in \routefolders\xxxxx "XXXXX" (searching in ALL SUBFOLDERS) do nothing
if there is no file newer than 2 years print in a file and delete the folder and subfolders \routefolders\xxxxx
The "XXXXX" folders are user-personal folders, if the user not use this i want to save a log and then to delete this folder
I have this, to delete a specific folder. I need some PS like this:
$RootDir="c:\temp\test"
$Users = Get-ChildItem $RootDir -Name
$FolderToDelete = "subcarpeta1"
foreach ($user in $Users){
$n = $n +1
write-host $n $user
#Remove-Item -path $rootdir\$user\$FolderToDelete -Force -Recurse
}