As far as I can tell by looking at other posts, using the subprocess library in Python is the most popular way to execute PowerShell commands from within Python. For example:
data = subprocess.check_output(["powershell.exe", "Connect-AzureAD -AccountId me@me.com \n Get-AzureADAuditSignInLogs"]).decode(sys.stdout.encoding)
I have tested in my environment
import requests
import json
url = 'https://graph.microsoft.com/v1.0/auditLogs/signIns'
token = "access_token"
headers = {
'Authorization': 'Bearer {}'.format(token)
}
user_response_data = json.loads(requests.get(url, headers=headers).text)
print(user_response_data)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.