Last active
July 16, 2024 01:03
-
-
Save dansmith65/a862f301fce553b26db9689ad0f87b6a to your computer and use it in GitHub Desktop.
Install latest 64-bit version of Nodepad++ via PowerShell
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
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
$homeUrl = 'https://notepad-plus-plus.org' | |
$res = Invoke-WebRequest -UseBasicParsing $homeUrl | |
if ($res.StatusCode -ne 200) {throw ("status code to getDownloadUrl was not 200: "+$res.StatusCode)} | |
$tempUrl = ($res.Links | Where-Object {$_.outerHTML -like "*Current Version *"})[0].href | |
if ($tempUrl.StartsWith("/")) { $tempUrl = "$homeUrl$tempUrl" } | |
$res = Invoke-WebRequest -UseBasicParsing $tempUrl | |
if ($res.StatusCode -ne 200) {throw ("status code to getDownloadUrl was not 200: "+$res.StatusCode)} | |
$dlUrl = ($res.Links | Where-Object {$_.href -like "*x64.exe"})[0].href | |
if ($dlUrl.StartsWith("/")) { $dlUrl = "$homeUrl$dlUrl" } | |
$installerPath = Join-Path $env:TEMP (Split-Path $dlUrl -Leaf) | |
Invoke-WebRequest $dlUrl -OutFile $installerPath | |
Start-Process -FilePath $installerPath -Args "/S" -Verb RunAs -Wait | |
Remove-Item $installerPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tomasgursky That actually did not take as much effort as I expected. Here is my detection script if you put it in a remediation. This matches when the notepad++ exe is either missing or not up to date. If you want to run this at the end of a script rather than as a separate detection script, then change $RemediationScript to $false