Skip to content

Instantly share code, notes, and snippets.

@santisq
Created September 13, 2023 01:14
Show Gist options
  • Save santisq/031812efc045b19eab2dc073361c0c02 to your computer and use it in GitHub Desktop.
Save santisq/031812efc045b19eab2dc073361c0c02 to your computer and use it in GitHub Desktop.
how to perform OnRemove in C#
Add-Type '
using System;
using System.Management.Automation;
namespace IModuleAssemblyCleanupTest;
public class Testing : IModuleAssemblyCleanup
{
public void OnRemove(PSModuleInfo psModuleInfo) =>
Console.WriteLine("Hello!");
}' -PassThru |
Import-Module -Assembly { $_.Assembly } -PassThru |
Remove-Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment