Newbie needs command line tool assistance

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
phurious
Posts: 15
Last visit: Tue Oct 15, 2019 12:06 pm

Newbie needs command line tool assistance

Post by phurious »

As part of a larger script, I am attempting to use NETSH to do some packet capture. Though I can get the command to run successfully from the command line, Powersehll ISE, and Console, the command absolutely refuses to run from within Powershell Studio (unless I specify it be run from console) and fails from within an EXE.
  1. $netsh = 'C:\Windows\System32\netsh.exe'
  2. $netshSwitches = "trace start capture=yes persistent=yes scenario=netconnection maxsize=400MB tracefile=MACHINE_NET_TRACE.ETL"
  3. Start-Process $netsh -ArgumentList $netshSwitches
Can anyone tell me what I need to do in order to get the command to run correctly?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Newbie needs command line tool assistance

Post by Alexander Riedel »

Can you define 'fail'. What error message are you getting?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
phurious
Posts: 15
Last visit: Tue Oct 15, 2019 12:06 pm

Re: Newbie needs command line tool assistance

Post by phurious »

That is just it; I receive no errors but the ETL file fails to be created. If the same command is run within the Powershell ISE, on the same machine, the ETL file is created and the process runs until the "netsh trace stop" command is issued.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Newbie needs command line tool assistance

Post by Alexander Riedel »

Two potential problems.
1. Permisssions. ISE and console run elevated by default. You can try packaging with a manifest that requires elevation.
2. Bit level. C:\Windows\System32 is a mapped folder. If you package as a 32 bit app, it wont work on a 64 bit machine.

You can press the elevate button in Powershell studio and see if that makes a difference. Ensure that you have selected the proper platform in the platform selector.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 7 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.