October 8, 2015 at 2:22 pm
Hi, I need help to get file count from the directory "T:/System Volume information" from a remoter server
I'm trying to run below PSEXEC command but its failing.
psexec \\MYSERVER28 -S cmd DIR "T:\System Volume Information" /b/a-d | find /v /c "::"
how can i achieve the file count on remote server.
October 8, 2015 at 8:09 pm
If remote command execution is open between the servers or computers you can use Invoke-Command:
Invoke-Command -Computer MYSERVER28 {(dir 'T:\System Volume Information').Count}
Shawn Melton
Twitter: @wsmelton
Blog: wsmelton.github.com
Github: wsmelton
October 21, 2015 at 3:08 pm
Thanks a lot Shwan. this little command works like charm. One last think. how can i delete files remotely in the same remote directory path?
October 21, 2015 at 3:23 pm
If you are not concerned with it and just to delete it all, just pipe that dir command to "Remove-Item -force".
If you need only certain files deleted then just add addition code in the brackets using the dir to just get those files you want, and then pipe to the remove command.
So if I only want to delete text files:
Dir *.txt | remove-item
You can add in "-what if" to verify what would get deleted.
Shawn Melton
Twitter: @wsmelton
Blog: wsmelton.github.com
Github: wsmelton
October 26, 2015 at 12:27 pm
Wow !! thanks for the tip. works like charm. thanks a milion.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply