Files and Folders

I am new to powershell and i have given a task.My task is i have multiple folders like

I need to check if there is a file under C:\Test\ and C:\Test\A\ then i need to get the file size but at the same time i need to exclude C:\Test\B\ and send email and i need to display all the files like this:

123.txt Size
124.ttx size

Kindly help me on this.

Are you only looking to access a parent folder (test) and one subfolder (a)? Or are you only excluding one subfolder (b)? If there are only 2 subfolders then the logic works both ways but it depends how you want your script to handle c:\test\c.

Writing code on an ipad in a hotel room is tricky so I’ll give some suggestions.

The obvious start is get-childitem c:\test and from there you will filter down to the files you want to list. My first thought is to use -recurse and then pipe the result to where {$_.foldername -eq ‘b’} (that’s probably the wrong property name, you will need to check). A final pipe to select name, length should do it (length is size for files as I recall). This is off the top of my head of course so you would need to test and expand on it.

Hey Matt,

Thanks very much for the help.It worked.