Getting the folder and sub folder information in a particular drive or path through power shell
The below Powershell query will extract the folder and sub folder info in the given path. I just mention here folder names -path showing as "MainFolder" and "SubFolder". In this place you provide your needed folders.
-Exclude: This is a parameter to which we need to pass extension of files, which we are expecting not to show in the result set.
Clear
Get-ChildItem `
-Path \\MainFolder\Sub\Sub1 `
-Exclude *.dtsx,*.sql*,*.onepkg*,*.docx*,*.doc*,*.log* -Recurse|
Where-Object {$_.Name -like "*Full_*"}
#Will provide DIFF info
#clear
Get-ChildItem `
-Path \\MainFolder\Sub\Sub1 `
-Exclude *.dtsx,*.sql*,*.onepkg*,*.docx*,*.doc*,*.log* -Recurse|
Where-Object {$_.Name -like "*Diff_*"}
# The below query will handle above both the queries.
clear
Get-ChildItem `
-Path E:\SQLBackups\Backups `
-Exclude *.dtsx,*.sql*,*.onepkg*,*.docx*,*.doc*,*.log* -Recurse|
Where-Object {($_.Name -like "*Full_*") -or
($_.Name
-like "*Diff_*")}|
Select-OBject Directory,Name,LastWriteTime|
Sort-Object -Property
LastWriteTime -desc
Comments