I have written a Powershell module that contains cmdlets that utilize IIS's WebAdministration
Powershell module. However, this module requires that it be loaded into an admin Powershell session, otherwise an exception is thrown. As you might know or guess, my custom module fails to load when Powershell is not first run as an admin.
This behavior is acceptable and expected. My question is whether or not there is a way to elevate the shell's permissions (and obey UAC settings) when this module is loaded?
Example: (Assume in this particular case, Import-Module WebAdministration
is found in my powershell profile)
- I click the powershell shortcut on my task bar.
- A powershell shell with standard user permissions opens, and attempts to import module.
- Encounters fact the module needs elevated permissions.
- User is prompted to do so and powershell restarts.