I'm new to Azure automation, and have a python script that runs fine on the local machine. The script runs a PowerShell command to get sign in logs, and does some string parsing on them before writing to a storage account table. I was able to install all dependencies for the script via the "Python Packages" blade in the automation account. Is there a way to add powershell.exe somewhere so that the subprocess library can be used to run the PowerShell command? Alternatively, is there a library you can import to be able to run the PowerShell command or grab sign in logs from Azure AD without directly using the powershell.exe file?
Am I just using the wrong filename and should use something other than powershell.exe? Is there a different module you have to install, or am I referencing it wrong?
import subprocess
import sys
import json
import azure.core
from azure.core.credentials import AzureNamedKeyCredential
from azure.data.tables import TableServiceClient, TableClient
data = subprocess.check_output(["powershell.exe", "Connect-AzureAD -AccountId placeholder@placeholder.com \n Get-AzureADAuditSignInLogs"]).decode(sys.stdout.encoding)
I have tested in my environment
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.