Last active
October 12, 2019 21:02
-
-
Save MauRiEEZZZ/57ed4192a4d6affe6ee53fc8b8087b0b to your computer and use it in GitHub Desktop.
Download Sysmon.exe from https://live.sysinternals.com
This file contains 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
function DownloadSysmon { | |
[cmdletbinding()] | |
Param() | |
$Result = $(Test-Path (Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath sysmon.exe)); | |
if(-not $Result) { | |
try { | |
# https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx | |
$tmpfile = [System.IO.Path]::GetTempFileName() | |
$null = Invoke-WebRequest -Uri 'https://live.sysinternals.com/Sysmon.exe' ` | |
-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