Wednesday, May 4, 2016

Deleting remote files via powershell

Here is a handy function useful in many scripts.

function delete-remotefile {
    PROCESS {
                $file = "\\$_\c$\temp\temp.txt"
                if (test-path $file)
                {
                echo "$_ File Exists"
                Remove-Item $file -force
                echo "$_ File Deleted"
                }
            }

No comments:

Post a Comment