19

I'm trying to execute in my powershell script the command below :

D:\Apps\Documentum\product\7.3\bin\idql.exe -udmadmin -pPassword dctm04 -RC:\temp\documentum\session_list.txt -w20 > C:\temp\documentum\session_logstash.txt

In my powershell script I do that:

$DOCBASE="dctm04"
$USER_DOCBASE="dmadmin"
$USER_PWD="Password01"
$IDQL_PATH="D:\Apps\Documentum\product\7.3\bin"
$QRY_SESSIONS="C:\temp\documentum\session_list.txt"
$QRY_LOG_SESSIONS="C:\temp\documentum\session_logstash.txt"

$IDQL_PATH\idql.exe -u$USER_DOCBASE -p$USER_PWD $DOCBASE -R$QRY_SESSIONS -w20 > $QRY_LOG_SESSIONS

But it doesn't work properly, I receive the error below :

At C:\temp\documentum\Generate.ps1:49 char:13
+   $IDQL_PATH\idql.exe -u$USER_DOCBASE -p$USER_PWD $DOCBASE -R$QRY_SESSIONS -w20  ...
+             ~~~~~~~~~
Unexpected token '\idql.exe' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

I think, i don't use variable properly on my command.

Please note my powershell version is :

PS C:\temp\documentum> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

could you give me the solution in order to solve my problem

4
  • 2
    Please edit the question and add more details. What, exactly, does " it doesn't work properly" mean? Nothing happens? An error message appears? Wrong results? Commented Aug 3, 2018 at 11:24
  • 2
    How does it not work properly? What error messages are you getting? What version of PowerShell are you using? Are you using the ISE, or the console? Are you running as Administrator, or as an ordinary user? There's a whole host of information you need to provide before we can be of any help to you... Commented Aug 3, 2018 at 11:24
  • ok I added more informations to my question Commented Aug 3, 2018 at 11:37
  • What about using Join-Path and/or Test-Path to assure the file exists? Commented Aug 3, 2018 at 12:09

1 Answer 1

23

The reason is that combining a string to executable name makes no sense to Powershell's parsing rules. Use the call operator & or Invoke-Item. Like so,

$ssms="C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio"
PS C:\> $ssms\ssms.exe
At line:1 char:6
+ $ssms\ssms.exe
+      ~~~~~~~~~
Unexpected token '\ssms.exe' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

C:\>& $ssms\ssms.exe
# Launches SSMS succesfully

C:\>Invoke-Item $ssms\ssms.exe
# Launches SSMS succesfully

There's nice a document about running executables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.