Skip to content

Instantly share code, notes, and snippets.

@MauRiEEZZZ
Last active October 12, 2019 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MauRiEEZZZ/57ed4192a4d6affe6ee53fc8b8087b0b to your computer and use it in GitHub Desktop.
Save MauRiEEZZZ/57ed4192a4d6affe6ee53fc8b8087b0b to your computer and use it in GitHub Desktop.
Download Sysmon.exe from https://live.sysinternals.com
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