I have the following command that I can run in cmd.exe
:
"C:\Program Files (x86)\FireEye\xagt\xagt.exe" -g "C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt"
I just need to run the above mentioned command in PowerShell.
I tried to use the symbol &
before the command, but I got an error. I also tried to use the following commands:
###########################
$cmd = 'C:\Program Files (x86)\FireEye\xagt\xagt.exe'
$arg1 = '-g C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt'
& $cmd $arg1
########################################
Start-Process -FilePath "xagt.exe" -WorkingDirectory "C:\Program Files (x86)\FireEye\xagt" -ArgumentList "-g "C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt""
############################################
PS C:\Program Files (x86)\FireEye\xagt> & 'xagt.exe -g "C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%%date:~-7,
_%time:~0,2%%time:~3,2%%time:~6,2%.txt"'
& : The term 'xagt.exe -g
"C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt"' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & 'xagt.exe -g "C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%% ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (xagt.exe -g "C:...time:~6,2%.txt":String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Program Files (x86)\FireEye\xagt> Invoke-Command -ScriptBlock {
>> xagt.exe -g "C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6
%.txt"
>> }
xagt.exe : The term 'xagt.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:2 char:8
+ xagt.exe -g "C:\tmp\xagt_%computername%_%date:~-4,4%%date:~-10 ...
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (xagt.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
All trials were not successful , there is something in thd syntax that I cannot understand.