0

In my custom powershell provider I want the user to be able to skip the internal call to InitializeDefaultDrives.

The InitializeDefaultDrives method is called when the provider starts. I guess this is when I use the Add-SnapIn cmdlet to load my provider. So it looks like i'm searching for a way to add dynamic parameters to to the Add-SnapIn cmdlet.

I know i can just skip the implementation of InitializeDefaultDrives and have the user use new-PsDrive to add the drive manually if desired. That is not want I want. I want to always create a default drive except in the case where the user wants to skip this.

Thanks!

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
RvS
  • 1

1 Answers1

1

AFAIK dynamic parameters only work when you control the source code i.e. in your code you can choose to expose a dynamic parameter based on the value of another parameter (like a path). Then your code does something different based on the value of the dynamic parameter. However, you should be able to accomplish what you want via a session preference variable.

$SuppressDriveInit = $true
Add-PSSnapin Acme

If the variable is not definied or is set to false, then go ahead and initialize the drive. It is low tech but should work fine.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369