Back up file on remote server with PowerShell

function RemoteCopy {
	Set-Location "e:\somepath\somedir"
	copy-item somefile.properties "somefile.properties.$(get-date -f yyyyMMdd)" -Force
}

Invoke-Command -ComputerName someserver -ScriptBlock ${function:RemoteCopy}
Advertisements