Running a command from the CMD prompt in Powershell RRS feed

  • Question

  • New to Powershell:

    I have to run a command from the CMD prompt because it will not work in Powershell. I think I understand how to run it from the CMD prompt by using "cmd /c"? I tested my script on a test machine with a simple "Hostname" command and it worked, but when I try it from the server with the actually command it does not work. I'm confused how to first navigate to the folder to run the command in Powershell. What am I missing? Here is what I tried, but I'm getting an error and the command wont run.

    I'm sure it is something simple that I am missing


    $var = (cmd /c "C:\Program Files (x86)\nCipher\nfast\bin>anonkneti")
    cmd /c "C:\Program Files (x86)\nCipher\nfast\bin>anonkneti"
    If($var.length -eq 55)
    Write-EventLog –LogName "Application" –Source “Cipher" –EntryType "Information" –EventID 9999 -Message "Connection Successful"
    Write-EventLog –LogName "Application" –Source “Cipher” –EntryType "Error" –EventID 9998 -Message "Error - RemoteServerFailed"


    Thank you kindly!

    Friday, June 26, 2020 4:15 AM

All replies

  • Your command syntax is bad.  It has illegal characters.

     cmd /c "C:\Program Files (x86)\nCipher\nfast\bin>anonkneti"

    You have a ">" in the path.  This is illegal in a path and is not a path separator character.


    Friday, June 26, 2020 5:42 AM
  • Thank you for the response, jrv.
    Friday, June 26, 2020 2:19 PM