0

I started learning Python this week, and I am trying to automate adding a new user to both active directory, and on Office 365.

I have managed to add the user to AD using a client and a bot, and also use another script to generate the correct New-MsolUser syntax for Powershell.

How do I get Python to open Powershell and run the output of "o365command"?

Also will I need to connect to the tenant every time I do this so will I need to incorporate this into the script as well?

Happy to show the code I have if needed.

D_00
  • 1,440
  • 2
  • 13
  • 32
MaseyG
  • 1
  • 2
  • Does this answer your question? [Run PowerShell function from Python script](https://stackoverflow.com/questions/14508809/run-powershell-function-from-python-script) – marsze Apr 30 '21 at 11:29

1 Answers1

0

If you provide the output from Python as JSON to a file, then PowerShell can import that directly. See ConvertFrom-Json (ConvertFrom-Json).

As for running PowerShell from Python, look at: Running an outside program (executable) in Python? It's not something I've ever tried but good luck.

StephenSo
  • 141
  • 1
  • 4