To import a single module: Create a wrapper script with full bypass to execute the ps1 involved in importing dbatools module (such as typealiases.ps1).
Create a wrapper script, (Example: wrapper_dbatools.bat), which will invoke the ps1 being blocked. Example below. Note: Do not actually use c:\temp or the name below. The name and location should be customized.
Next, give this wrapper script a PERMISSION, to FULL BYPASS OPERATION
*\temp\wrapper_dbatools.bat --> Performs any Operation –> Bypass
The script can be ran with a new instance of "cmd.exe" as follows:
c:\temp>cmd /c wrapper_dbatools.bat
If DBA Tools is needed in "interactive mode: have the wrapper script open a powershell prompt from which all subsequent commands will be allowed to run.
Example wrapper script content:
start powershell.exe
Additional Information
The wrapper script (.bat examples shared above) should be kept confidential/internal information since it provides unrestricted Powershell access. Other security measures such as NTFS / file permissions may be implemented for additional control.
Additional approval mechanisms are being investigated for DBA Tools 2.0. This work is being tracked under CRE-18287 and is scheduled for an October release. No permissions rules should be required after that time.