I have created a module that requires the sqlps module in order to work. The module I have created is a module manifest. Within the module manifest i have the following line NestedModules = @(‘sqlps’, DatabaseDeployment’, ‘etc’). This loads the sqlps module before loading the DatabaseDeployment module etc. I have a couple of questions.
Is there a way to load the sqlps module with disable name checking enabled but keeping the sqlps module local to my modules scope.
Is there a way of executing code to initialize the environment after the modules have loaded. ScriptsToProcess seems to execute prior to loading the modules. I want to do this to change the PSDrive.
Is there a way to include all of the functions, cmdlets etc for export excluding the sqlps ones. I don’t want to expose sqlps I just want to consume it. Currently i am using FunctionsToExport = ‘*’.
Is there a way to load the sqlps module with disable name checking enabled but keeping the sqlps module local to my modules scope.
You could load the module from within your script module. That’d give you the ability to only export the commands you want - which can exclude anything in sqlps. Or, you can accomplish the same thing in the manifest, if you prefer.
Is there a way of executing code to initialize the environment after the modules have loaded. ScriptsToProcess seems to execute prior to loading the modules. I want to do this to change the PSDrive.
Any code in the root module that isn’t in a function will run with the module loads.
Is there a way to include all of the functions, cmdlets etc for export excluding the sqlps ones. I don’t want to expose sqlps I just want to consume it. Currently i am using FunctionsToExport = ‘*’.
Change FunctionsToExport to include only yours. If you were smart and put a noun prefix on yours, then you can use a partial wildcard.
Don thanks for taking the time to answer my question, everything worked as you suggested. I think that I will leave the sqlps import where it is, otherwise remove-module MyModule will not remove sqlps as it will have been defined outside of the scope of the module. Or at least that is my understanding.