AndrewRathbun / KAPE-EZToolsAncillaryUpdater

A script that updates KAPE (using Get-KAPEUpdate.ps1) as well as EZ Tools (within .\KAPE\Modules\bin) and the ancillary files that enhance the output of those tools
MIT License
53 stars 5 forks source link

Add Test-Path for .NET 6 Desktop Runtime #4

Open AndrewRathbun opened 2 years ago

AndrewRathbun commented 2 years ago

From Phill Moore (@randomaccess3):

$url = "https://dot.net/v1/dotnet-install.ps1"
$output = "$PSScriptRoot\dotnet-install.ps1"

Set-location $PSScriptRoot
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)
(New-Object System.Net.WebClient).DownloadFile($url, $output)

.\dotnet-install.ps1 -runtime windowsdesktop

https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

AndrewRathbun commented 2 years ago

Figure out a way to download the offline installer predictably

AndrewRathbun commented 2 years ago

dotnet --list-runtimes

Donovoi commented 2 years ago

Happy to work on this. Are we wanting to check if .net 6 runtime is installed. If not, download and install it? Or are we aiming for something else?

AndrewRathbun commented 2 years ago

Happy to work on this. Are we wanting to check if .net 6 runtime is installed. If not, download and install it? Or are we aiming for something else?

Yep this is a feature request by @randomaccess3 for exactly that. However, maybe he can chime in as to what would work best for his use case.

AndrewRathbun commented 2 years ago

I imagine a version checker could be implemented that queries the runtime version installed locally and checks if the current version of .NET 6 is installed. Probably similar logic to the script version checker.

mark-hallman commented 1 year ago

It is a good feature to have. I imagine that there are folks that want to install KAPE and might not even understand what .net is. For my current VMs for the DFIR classes at SANS it is not that useful because my base VM has all these prerequisites, but I still think it adds value to the script.

Donovoi commented 1 year ago

I imagine a version checker could be implemented that queries the runtime version installed locally and checks if the current version of .NET 6 is installed. Probably similar logic to the script version checker.

winget does this but not in the best way, it just checks if any .net sdk or runtime are installed even if it is different versions (e.g 7 vs Preview ). So if we do go down the winget avenue, be sure to add the --force switch.

I've got a cheeky one liner in my PowerShell profile for my tool update script:

Start-Process -FilePath pwsh.exe -ArgumentList '-noexit -command "$(@(3,5,6,7,""Preview"").foreach{winget install Microsoft.DotNet.SDK.$($_) --force})"'

If you ever wanted to use something similar :)

To check the dotnet installed, I'd use a combination of winget and Stéphane BARIZIEN's script found here https://gist.github.com/sba923/7924b726fd44af91d18453ee595e6548

$wingetobjects = winget list "Microsoft .NET SDK 6" | cfwo

cfwo is an alias for ConvertFrom-WingetStdout which is a very helpfull cmdlet that returns objects from winget output instead of just writing to stdout.

An awesome example of how this can work is: https://user-images.githubusercontent.com/585482/200775771-3caca3d3-9906-40fb-9d5b-ac455c01e217.gif