Skip to content

Instantly share code, notes, and snippets.

Last active October 12, 2019 21:02
What would you like to do?
Download Sysmon.exe from
function DownloadSysmon {
$Result = $(Test-Path (Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath sysmon.exe));
if(-not $Result) {
try {
$tmpfile = [System.IO.Path]::GetTempFileName()
$null = Invoke-WebRequest -Uri '' `
-OutFile $tmpfile -ErrorAction Stop
Write-Verbose 'Sucessfully downloaded Sysmon.exe'
Unblock-File -Path $tmpfile -ErrorAction Stop
$exefile = Join-Path -Path (Split-Path -Path $tmpfile -Parent) -ChildPath 'a.exe'
if (Test-Path $exefile) {
Remove-Item -Path $exefile -Force -ErrorAction Stop
$tmpfile | Rename-Item -NewName 'a.exe' -Force -ErrorAction Stop
} catch {
Write-Verbose "Something went wrong $($_.Exception.Message)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment