Run python script using Powershell loop…

Welcome Forums General PowerShell Q&A Run python script using Powershell loop…

Viewing 3 reply threads
  • Author
    Posts
    • #260340
      Participant
      Topics: 4
      Replies: 3
      Points: 43
      Rank: Member

      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:

       

       

      I also need to make sure that the next execution only follows the completions of the preceding one

      Many thanks

    • #260358
      Senior Moderator
      Topics: 9
      Replies: 1373
      Points: 5,061
      Helping Hand
      Rank: Community MVP

      Try use python3 <filepath.py>.

      • This reply was modified 3 weeks, 4 days ago by kvprasoon. Reason: post correction
    • #260382
      Participant
      Topics: 4
      Replies: 3
      Points: 43
      Rank: Member

      Many thanks for your reply,

      I found the following worked ok…

      However I am now stumped as to output the returning text from the Python script

      Any ideas on how I can do this?

       

       

      Thanks

    • #260391
      Senior Moderator
      Topics: 9
      Replies: 1373
      Points: 5,061
      Helping Hand
      Rank: Community MVP

      Are you referring to capture the output ? you can save it in a variable like $r = python sample.py.
      You can even capture the output from foreach like below

      • This reply was modified 3 weeks, 4 days ago by kvprasoon. Reason: post correction
      • This reply was modified 3 weeks, 4 days ago by kvprasoon. Reason: post correction
Viewing 3 reply threads
  • You must be logged in to reply to this topic.