Skip to content

Instantly share code, notes, and snippets.

@bradymholt
Created March 6, 2015 01:51
Show Gist options
  • Save bradymholt/3957c140b816007a19a8 to your computer and use it in GitHub Desktop.
Save bradymholt/3957c140b816007a19a8 to your computer and use it in GitHub Desktop.
Touches a remote file by updating LastWriteTime - useful for touching a remote web.config to restart ASP.NET AppDomain
param ($computerName, $username, $password, $targetFile)
trap
{
write-output $_
exit 1
}
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PsCredential($username, $securePassword)
Invoke-Command -ComputerName $computerName -Credential $credentials -ScriptBlock { $file = Get-Item $args[0]; $file.LastWriteTime = (Get-Date) } -ArgumentList $targetFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment