Skip to main content

Manage - DotNetRunTime

Overview​

This NinjaOne automation helps keep .NET components on Windows devices clean, current, and secure. It supports listing installed .NET components, installing the latest supported versions, updating patch releases, uninstalling unsupported or specifically targeted versions, and performing a complete cleanup and refresh. It can also keep versions that Microsoft no longer supports, such as .NET 8 and .NET 9, installed and patched for the applications that still need them.

The automation uses Microsoft's release data to determine the appropriate versions to install, update, or remove. Versions entered in AdditionalApprovedVersion are treated as supported too. It reads configuration from NinjaOne custom fields and downloads and executes the agnostic Optimize-DotNetRunTime.ps1 script from ProVal's content repository.

Depending on the selected action, the automation may download installers, silently install updates, and remove existing .NET components. Execution details are written to log files under %ProgramData%\_Automation\Script\Optimize-DotNetRunTime.

⚠️ WARNING: .NET 8 and .NET 9 reached end of support on November 10, 2026. See Microsoft's announcement. Since then, uninstall and renew remove them and update no longer patches them. To keep them for applications that still need them, enter 8, 9 in AdditionalApprovedVersion on every run, including scheduled runs.

NOTE:

  • Installing or uninstalling sdk can also install or remove related aspNetCoreRuntime, desktopRuntime, and runtime components.
  • Installing or uninstalling desktopRuntime can also install or remove the related runtime.
  • For actions other than list, if Type is not provided, the script uses desktopRuntime by default.
  • Install and update use the machine's native architecture installer (for example, x64 installer on x64 machines).
  • If x86 components already exist on a machine, the script can detect and remove outdated x86 components during uninstall, update, and renew.
  • Use Version carefully:
    • For list, install, uninstall, and update, you can target specific major versions (including unsupported versions).
    • For renew with Version, every specified version must be supported or listed in AdditionalApprovedVersion. If any are not, the action will stop.
  • Use AdditionalApprovedVersion to treat out-of-support major versions as supported for the current run:
    • Approved versions are kept by uninstall and renew, and patched by update and renew.
    • Approvals are not saved. Enter the same list on every run that should keep those versions.
    • AdditionalApprovedVersion does not install anything. To add a version that is missing from a device, enter it in Version with install or renew, as in Example 13.
    • Version takes priority over an approval. uninstall with 8 in Version removes .NET 8 even when it is approved, and renew with Version removes every version that is not listed in Version.
    • Approved versions no longer receive fixes from Microsoft. Approve a version only while an application still needs it.
  • Version and AdditionalApprovedVersion accept numbers and commas only. Any other text stops the automation before it changes anything.
  • Set Force to 1 to apply force removal behavior. Any other value (or blank) means force is not applied.
  • For uninstall, update, and renew, older-version cleanup primarily targets components detected by dotnet.exe. With Force = 1, cleanup can also remove .NET entries found through uninstall registry data and package metadata, including components that dotnet.exe does not list.
  • renew is the most aggressive option. It can remove versions you are not targeting. Review your required application dependencies before using it, and run list with your AdditionalApprovedVersion list first, as in Example 18, to see what would be removed.

Dependencies​

Sample Run​

Sample Run

Example 1: List all installed .NET components​

Sample Run

Example 2: List only .NET SDKs​

  • Action: list
  • Type: sdk

Sample Run

Example 3: Install the latest versions of all .NET components​

  • Action: install
  • Type: all

Sample Run

Example 4: Update SDKs to the latest patch version​

  • Action: update
  • Type: sdk

Sample Run

Example 5: Remove unsupported ASP.NET Core versions​

  • Action: uninstall
  • Type: aspNetCoreRuntime

Sample Run

Example 6: Removes all unsupported versions of .NET runtimes and SDKs and installs the latest available version​

  • Action: renew
  • Type: all

Sample Run

Example 7: Install the latest .NET Desktop Runtime (default type)​

  • Action: install

Sample Run

Example 8: Install .NET 10 Desktop Runtime​

  • Action: install
  • Type: desktopRuntime
  • Version: 10

Sample Run

Example 9: Install multiple specific versions​

  • Action: install
  • Type: desktopRuntime
  • Version: 8, 10

Sample Run

Example 10: Update only .NET 8 to the latest patch​

Patches only the .NET 8 Desktop Runtime, whether or not .NET 8 is still supported.

  • Action: update
  • Type: desktopRuntime
  • Version: 8

Sample Run

Example 11: Update multiple versions to their latest patches​

  • Action: update
  • Type: all
  • Version: 6, 7, 8, 9

Sample Run

Example 12: Remove specific .NET versions​

  • Action: uninstall
  • Type: all
  • Version: 6, 7

Sample Run

Example 13: Keep only .NET 8 and .NET 9 and remove all others​

Installs and patches .NET 8 and .NET 9, then removes every other version. .NET 8 and .NET 9 are out of support, so they are approved in the same run.

  • Action: renew
  • Type: all
  • Version: 8, 9
  • AdditionalApprovedVersion: 8, 9

Sample Run

Example 14: List only .NET 8 and .NET 9 components​

  • Action: list
  • Type: <Blank>
  • Version: 8, 9

Sample Run

Example 15: Keep only .NET 10 and remove all others​

  • Action: renew
  • Type: <Blank>
  • Version: 10

Sample Run

Example 16: Force renew to .NET 10 only​

  • Action: renew
  • Type: all
  • Version: 10
  • Force: 1

Sample Run

Example 17: Force uninstall .NET 8​

  • Action: uninstall
  • Type: all
  • Version: 8
  • Force: 1

Sample Run

Example 18: Preview what an approval keeps​

Shows the list with .NET 8 and .NET 9 marked as supported. Components that still show Supported as 0 are the ones uninstall and renew would remove. Nothing is changed.

  • Action: list
  • AdditionalApprovedVersion: 8, 9

Sample Run

Example 19: Update and keep .NET 8 and .NET 9 patched​

Patches every installed supported version, and installed .NET 8 and .NET 9 components as well, then removes their older patches.

  • Action: update
  • Type: all
  • AdditionalApprovedVersion: 8, 9

Sample Run

Example 20: Remove unsupported versions but keep .NET 8 and .NET 9​

Removes every out-of-support component except .NET 8 and .NET 9.

  • Action: uninstall
  • Type: all
  • AdditionalApprovedVersion: 8, 9

Sample Run

Example 21: Renew and keep .NET 8 and .NET 9​

Does the same as Example 6, but keeps .NET 8 and .NET 9 and patches them to their latest release.

  • Action: renew
  • Type: all
  • AdditionalApprovedVersion: 8, 9

Sample Run

Requirements​

  • Supported operating system and device role
  • Run As: System
  • PowerShell 5.1

User Parameters​

NameExampleAccepted ValuesRequiredDefaultTypeDescription
ActionInstall
  • list
  • install
  • uninstall
  • update
  • renew
FalseFalseString/TextOptional. Specify the action to perform. Valid values: list, install, uninstall, update, renew. Defaults to 'list' when empty.
Typeall, sdk, runtime
  • sdk
  • runtime
  • desktopRuntime
  • aspNetCoreRuntime
  • all
FalseFalseString/TextOptional. Comma-separated .NET component types to manage. Valid values: sdk, runtime, desktopRuntime, aspNetCoreRuntime, all.
Version8, 9
  • 8
  • 9
  • 8, 9
FalseFalseString/TextOptional. Comma-separated .NET major version numbers (e.g., 8 or 8, 9, 10) to scope the action to. Out-of-support versions are accepted, except by renew, which needs every listed version to be supported or approved.
AdditionalApprovedVersion8, 9
  • 8
  • 9
  • 8, 9
FalseString/TextOptional. Comma-separated out-of-support .NET major version numbers (5 or later) to treat as supported for this run. They are kept by uninstall and renew, and patched by update and renew. When empty, only the versions Microsoft supports are treated as supported.
ForceChecked, Unchecked
  • 1
  • Yes
  • True
  • Blank
FalseFalseCheckBoxOptional. Check this box to force removal of components bypassing MSI dependency providers. CAUTION: May cause dependent applications to malfunction..

Tips for Version and AdditionalApprovedVersion Behavior​

ActionWithout VersionWith Version (e.g., Version 8, 9)With AdditionalApprovedVersion (e.g., 8, 9)
listShows all installed .NET componentsShows only versions 8 and 9Shows the approved versions as supported
installInstalls the latest supported versionInstalls the latest release for each specified version (EOL included with warning)No change
updateUpdates only supported installed versionsUpdates the specified version(s), including EOLAlso updates the approved versions that are installed
uninstallRemoves only unsupported/EOL versionsRemoves the specified version(s), including supportedKeeps the approved versions
renewInstalls latest supported + removes all unsupportedKeeps only specified version(s), removes everything else. Aborts if any version is EOL and not approved.Keeps and patches the approved versions

Force Parameter - Caution​

⚠️ WARNING: The Force parameter overrides Windows Installer dependency protection. Use only when you fully understand the implications.

Without Force (or Force = false), the script respects MSI dependency providers registered by other applications. If software such as Visual Studio, SQL Server, or third-party tools installed a .NET component and registered a dependency on it, the Windows Installer will silently refuse to remove it (returning exit code 0) to protect the dependent application. This is by design.

When Force = True, the script appends IGNOREDEPENDENCIES=ALL to all MSI uninstall commands, which:

  • Bypasses the dependency provider safety check.
  • Forces removal of the .NET component regardless of what other software depends on it.
  • May cause dependent applications to malfunction, fail to start, or require repair/reinstallation.

When to use Force = 1:

  • You are certain no critical software depends on the targeted .NET version.
  • You are performing a controlled upgrade where a newer version will immediately replace the removed one (e.g., Action: renew, Version: 10, Force: 1 installs .NET 10 before removing older versions).
  • You need to clean up orphaned registry entries from partially removed installations.

When NOT to use Force = 1:

  • On systems with Visual Studio, SQL Server, or other enterprise software that bundles .NET runtimes.
  • On shared or production servers where breaking a dependency could disrupt services.
  • When you are unsure which applications depend on the .NET components being removed.

Automation Setup/Import​

Output​

  • Activity Details
  • %ProgramData%_Automation\Script\Optimize-DotNetRunTime\Optimize-DotNetRunTime-log.txt
  • %ProgramData%_Automation\Script\Optimize-DotNetRunTime\Optimize-DotNetRunTime-error.txt

Changelog​

2026-11-10​

  • Initial version of the document