ImportPSModule Failure Detection
问题 I am trying to use InitialSessionState.ImportPSModule in order to import a Powershell module. I am interested in knowing if importing of the module failed due to any reason (e.g file not found etc.). Putting such code in the try block does not raise an exception in the case of failure and the function seems to fail silently and continue if it is not able to import the module. Is there a way to be alerted in the code if the import fails? I am trying to do something like the following. In the