Advertisement
Yevrag35

Import Module Runspace

Nov 16th, 2020
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $initialState = [System.Management.Automation.Runspaces.InitialSessionState]::Create()
  2. $initialState.ImportPSModule("AzureAD")
  3.  
  4. $rsPool = [runspacefactory]::CreateRunspacePool($state)
  5. $rsPool.SetMaxRunspaces(10) # number of threads to run at once
  6. $rsPool.ApartmentState = "STA"
  7. $rsPool.ThreadOptions = "ReuseThread"
  8. $rsPool.Open()
  9. $code = {
  10.     param (#enter parameters here#)
  11.  
  12.     Connect-AzureAD #...
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement