Request powershell from python?

Tell me how you can run this query in one line or in two lines

If I use
str = os.system("powershell Get-ADUser -filter {name -like 'last Name'} ")
it gives me information, but I need to write it to a file

If I do this in powershell, in two lines, it works, and python is not..
$GFile = "C:\Users\result.txt" 
Get-ADUser -filter {name -like 'last Name'} | Out-File $GFile -encoding Unicode

str = os.system("powershell $GFile = 'C:/Users/result.txt' Get-ADUser -filter {name -like 'last Name'} | Out-File $GFile -encoding Unicode}")

"Out-File" is not internal or external
command, operable program or batch file.
April 3rd 20 at 17:46
1 answer
April 3rd 20 at 17:48
quotes send -command " & { #{script} } "

for example
powershell.exe -command "& {get-childitem -path '.' | select-object -first 1 | format-list }"

 Directory: C:\Users\Serguei

Name : .cache

or via-file "#{script_filepath}"

Find more questions by tags PythonPowerShell