I am creating a Python script that calls a Powershell script script.ps1
that needs to import the Active-Directory module. However, every time I run the powershell script using
check_output('powershell.exe -File script.ps1')
it needs to re-import the active directory module for each run of script.ps1, which makes the run time take about 3 seconds longer then it needs to.
I was wondering then, if there was a way to keep the Powershell module imported (as if it were being ran directly from Powershell, and not from Python) so that I can use things like
if(-not(Get-Module -name ActiveDirectory)){
Import-Module ActiveDirectory
}
to speed up execution time.