Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:57:10+00:00 2026-05-29T09:57:10+00:00

I currently have a PowerShell script that is used for complex automated Exchange mailbox

  • 0

I currently have a PowerShell script that is used for complex automated Exchange mailbox management. At times, the script will be running 20-40 instances simultaneously. The body of the script itself doesn’t take much time to run; however, the script requires the ActiveDirectory module, the ServerManager module, and the Exchange 2010 PS-snapin. Loading these modules and snapins takes a few seconds when only 1 instance of the script is running. This is of course compounded once there are multiple instances of the script running. This ends up heading the box towards extremely high resource usage as it tries to load these modules 20-40 times simultaneously.

The question is this:

Is there someway to either keep the 3 required modules loaded into memory, so to speak, or is there some other way to optimize this that anyone can think of that will not require the loading of these 3 modules each time a new instance of the PowerShell script is called up?

Here is the basics of the script simplified (without: function bodies, if statements, error handling) – Let me know if you need any section added

CODE SNIPPIT:

param($ARG1,$ARG2,$ARG3) # Grab arguments from command line

# Load Modules
Import-Module ActiveDirectory
Import-Module ServerManager
Add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

# Pass Arguments to Variables
$username = $ARG1

# Create Functions
function checkValidADUser {}
function checkOldMailbox {}
function chooseMailstore {}
function createMailbox {}

# Run Functions
checkValidADUser $username
checkOldMailbox $username
chooseMailstore $username
createMailbox $username $mailstore
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:57:11+00:00Added an answer on May 29, 2026 at 9:57 am

    You can try and load just the cmdlets you need from each module.
    With regards to the AD module you can speed up its loading by disabling the loading of the default AD drive. Some AD operations are also available via the Exchange commands, maybe you can skip the AD module.
    By the way, loading the E2010 snap-in is not supported.

    $env:ADPS_LoadDefaultDrive = 0
    Import-Module ActiveDirectory -Cmdlet Get-ADUser,Set-ADUser
    Import-Module ServerManager ...
    Add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am have a powershell script that does a few things that all need
I have a Powershell script that reads values off of the pipeline: PARAM (
I have a SQL 2008 job that does database backups using a Powershell script.
I'm pretty new to Powershell. I have 2 different scripts I'm running that I
I am currently trying to write a little powershell script (I have no experience
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I have a PowerShell script that checks that a certain directory is on the
I have a powershell script that is replacing patterns in a file with the
I have a Powershell script that is loading a .NET assembly (.EXE in my
I have an application that I use to run Exchange Powershell commands inside C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.