Jump to content

Powershell command script block output


Go to solution Solved by Danyfirex,

Recommended Posts

Local $iPID = Run(@ComSpec & ' /c powershell -Command "' & '{Get-NetAdapter | Where-Object InterfaceType -eq 71}' & '"','',@SW_HIDE,6)
ProcessWaitClose($iPID)
ConsoleWrite(StdoutRead($iPID) & @CRLF)

Returns "Get-NetAdapter | Where-Object InterfaceType -eq 71"

Is there a way to get the output of the command instead of just the command itself that is being echoed back ?

Thanks

Link to comment
Share on other sites

  • Solution
Posted (edited)

Hello.

Add  & to 

 /c powershell -Command "' & ' & {Get-NetAdapter | Where-Object InterfaceType -eq 71}'

or

Remove { and }

 

Saludos

Edited by Danyfirex
Link to comment
Share on other sites

are you sure? 

 

this works for me:

Local $iPID = Run(@ComSpec & ' /c powershell -Command "' & '& {Write-Host "Danyfirex"}' & '"','',@SW_HIDE,6)
ProcessWaitClose($iPID)
ConsoleWrite(StdoutRead($iPID) & @CRLF)

 

 

Saludos

Link to comment
Share on other sites

Posted (edited)

Thanks for the help Danyfirex but you changed your reply afterwards...I was replying to your initial answer. The first suggestion  of your modified reply works: adding the ampersand. Second one does not. Second one works too !

Edit: must have made a typo somewhere first time around...sorry 😓

Edited by lowrider2025
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...