Author Posts

January 1, 2012 at 12:00 am

by willbs at 2013-04-10 12:53:50

i have this command for example

remove-item -path C:\serverfolders\users\*

i want to delete all of files in the "users" folder but i don't want to delete any subfolders whose names are unknown to me, any ideas?
is there an -exclude folders type command?

by ArtB0514 at 2013-04-10 12:59:21

Version 2:
Get-Childitem C:\serverfolders\users\* | Where-Object {-Not $_.PSIsContainer} | Foreach-Object {Remove-Item $_.FullName}

Version 3:
Get-Childitem C:\serverfolders\users\* -File | Foreach-Object {Remove-Item $_.FullName}

by willbs at 2013-04-10 13:40:25

that's a bingo, thanks Art

by ArtB0514 at 2013-04-10 13:44:43

You're very welcome.