Summary
Every cmdlet builds its own HttpClient and client instance per invocation; introduce a shared base class that owns auth, client lifetime, and common parameters.
What's working now
Every cmdlet authenticates through the active Connect-MgGraph session or -AccessToken, the pattern is proven against a live tenant, and the shared auth helper is emitted once per module.
How can we make it better
Each invocation constructs a fresh HttpClient/RequestAdapter/ApiClient, which wastes allocations. Emit a base cmdlet class per module that owns the client lifetime and session handling, and shrink the per-cmdlet template to its unique parts.
Summary
Every cmdlet builds its own HttpClient and client instance per invocation; introduce a shared base class that owns auth, client lifetime, and common parameters.
What's working now
Every cmdlet authenticates through the active Connect-MgGraph session or -AccessToken, the pattern is proven against a live tenant, and the shared auth helper is emitted once per module.
How can we make it better
Each invocation constructs a fresh HttpClient/RequestAdapter/ApiClient, which wastes allocations. Emit a base cmdlet class per module that owns the client lifetime and session handling, and shrink the per-cmdlet template to its unique parts.