$Path2Script = "C:\MonScript.ps1" $cert=(dir cert:\currentuser\my\ -CodeSigningCert) $LastChange = "" do{ $MonFile = Get-Item -Path $Path2Script if($MonFile.LastWriteTime -ne $LastChange ){ #Write-Host "Change ! : $LastChange vs $($MonFile.LastWriteTime)" Set-AuthenticodeSignature -FilePath $Path2Script -Certificate $cert -TimestampServer http://timestamp.sectigo.com $MonFile = Get-Item -Path $Path2Script $LastChange = $MonFile.LastWriteTime } Start-Sleep 1 } while (1 -ne 2)