<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Powershell Script and XDR in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/534378#M3832</link>
    <description>&lt;P&gt;Hello, I can share the PowerShell through python script I use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import subprocess
def windowsupdate():
    pscommand = 
    
"""

  
"""

    import subprocess;
    process=subprocess.Popen(["powershell","&amp;amp; {" + pscommand + "}"],stdout=subprocess.PIPE);
    result=process.communicate()[0]
    print (result)

windowsupdate()&lt;/LI-CODE&gt;
&lt;P&gt;Put all your PowerShell commands between the triple quotes in that big blank space. I haven't had issues with what PowerShell commands I can run. One thing to note is that you need to use forward slash's (/) if you're referencing a directory, otherwise XDR will have issues. Spent a few hours debugging before realizing that was the issue. Hope this helps!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 18:32:32 GMT</pubDate>
    <dc:creator>odonaldadmin</dc:creator>
    <dc:date>2023-03-14T18:32:32Z</dc:date>
    <item>
      <title>Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/529931#M3561</link>
      <description>&lt;P&gt;There is a PowerShell script that we would like to use within XDR. I understand that XDR currently is not able to run PowerShell scripts, the problem is I am not a coder. I have been trying to learn how to convert our script to Python but I am just about to give up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my research, I found some posts from users on various websites explaining that it is possible to run a PowerShell&amp;nbsp;script with Python and I wondered if this could be a workaround?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import subprocess, sys

p = subprocess.Popen(["powershell.exe", 
              "C:\\Scripts\\PS-ScriptWeNeed.ps1"], 
              stdout=sys.stdout)
p.communicate()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem I see is that the assumption is you are running this script from your own host and directing Python to the path where the PowerShell script is located on your host, therefore, this is not possible unless all host already have this file located in the same file path on each host. If that is the case, any other work arounds?&lt;BR /&gt;&lt;BR /&gt;If none of the above work, any chance anyone here could recommend a good resource that could help me with converting this script from PowerShell to Python?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 01:33:53 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/529931#M3561</guid>
      <dc:creator>james.cadet</dc:creator>
      <dc:date>2023-02-06T01:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/530094#M3573</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/268976"&gt;@james.cadet&lt;/a&gt;&amp;nbsp;how about using Python to retrieve the powershell script from a shared filesystem and executing it?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 23:27:43 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/530094#M3573</guid>
      <dc:creator>bbarmanroy</dc:creator>
      <dc:date>2023-02-07T23:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/531429#M3650</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/192661"&gt;@bbarmanroy&lt;/a&gt;&amp;nbsp;sorry for the delayed response, drowning in work haha. Thank you for that suggestion! I was actually working on trying to get that done but just was not able to. I keep getting errors regarding the syntax somewhere in the script and just could not figure it out and finally gave up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Decided it was better to just recreate the script in Python, so just bit the bullet and pulled an all-nighter trying to figure out how to get that done and it finally worked. Great learning experience but it did reinforce my original belief that coding is not for me lol.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again for trying to help!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 14:26:55 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/531429#M3650</guid>
      <dc:creator>james.cadet</dc:creator>
      <dc:date>2023-02-16T14:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/533075#M3759</link>
      <description>&lt;P&gt;Great work there&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/268976"&gt;@james.cadet&lt;/a&gt;&amp;nbsp;. If anything, it goes to show that you could do it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 01:52:39 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/533075#M3759</guid>
      <dc:creator>bbarmanroy</dc:creator>
      <dc:date>2023-03-03T01:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/533397#M3780</link>
      <description>&lt;P&gt;Do you still need a solution to get PowerShell script execution in XDR?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 02:38:50 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/533397#M3780</guid>
      <dc:creator>KanwarSingh01</dc:creator>
      <dc:date>2023-03-07T02:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/534378#M3832</link>
      <description>&lt;P&gt;Hello, I can share the PowerShell through python script I use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import subprocess
def windowsupdate():
    pscommand = 
    
"""

  
"""

    import subprocess;
    process=subprocess.Popen(["powershell","&amp;amp; {" + pscommand + "}"],stdout=subprocess.PIPE);
    result=process.communicate()[0]
    print (result)

windowsupdate()&lt;/LI-CODE&gt;
&lt;P&gt;Put all your PowerShell commands between the triple quotes in that big blank space. I haven't had issues with what PowerShell commands I can run. One thing to note is that you need to use forward slash's (/) if you're referencing a directory, otherwise XDR will have issues. Spent a few hours debugging before realizing that was the issue. Hope this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 18:32:32 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/534378#M3832</guid>
      <dc:creator>odonaldadmin</dc:creator>
      <dc:date>2023-03-14T18:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell Script and XDR</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/534384#M3833</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/163390"&gt;@KanwarSingh01&lt;/a&gt;&amp;nbsp;At this time it is no longer needed as I was able to rebuild the script in python. I appreciate you checking, however, I may be back and reach out to you for another script if I am unable to get that figured out&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 19:55:00 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/powershell-script-and-xdr/m-p/534384#M3833</guid>
      <dc:creator>james.cadet</dc:creator>
      <dc:date>2023-03-14T19:55:00Z</dc:date>
    </item>
  </channel>
</rss>

