Hi,
I need to run a Python Zerologon_tester.py script within a powershell script but have no idea how to do this
The python script zerologon_tester.py uses the following syntax:
.\zerologon_tester.py <DomainControllerHostname> <IP>
I want to use a powershell script such as the following and add the domain hostname and IP address into the python script using variables for the syntax, something as follows:
import-module activedirectory
$env:PATHEXT += ";.py"
$dchostname = get-addomaincontroller -filter * | select-object name,ipv4addpress
foreach ($dc in $dchostname){
.\zerologon_tester.py $dc.name $dc.ipv4address
}
I also need to make sure that the next execution only follows the completions of the preceding one
Many thanks
Did you try like this?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Afaik, you can run any command in a PS script that you could run at a CMD prompt.
So the code you show should work.
What is the problem?
Doesn't the PS script wait till the Phyton script completes?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
The python script runs, however the variables do not get added to the .py script syntax
Can I assume that this is not possible to mix Ps variables into a python script like this...
.\zerologon_tester.py $dc.name $dc.ipv4address
The error returned is from the Python script:
Tests whether a domain controller is vulnerable to the zerologon attack. Does not attempt to make any changes.
Note: dc-name should be the (NetBIOS) computer name of the domain controller.
Usage: zerologon_tester.py <dc-name> <dc-ip>
Thanks!
I personally never mixed PS and python, but this article seems to show how you can pass arguments
How to: Pass Arguments to Python Script via Powershell - Stack Overflow (stackoverflow.com)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
Thanks for the article it did help
Also I did have a typo in one of my select objects
The following script works fine,
The next thing I would like to be able to do is pull the returning lines of output to either a .csv or .txt file
'Success! DC can be fully compromised by a Zerologon attack.'
or
'Attack failed. Target is probably patched.'
Any ideas on how I can do this?
Many, many thanks again!
Did you try like this?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD