Created
March 6, 2015 01:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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