1

I have this below command when I run this command from cmd, it is running fine. However, in PowerShell it is not running, although it is not giving any error message. Can anyone help me out to write the correct code with arguments as server_name and Nessus_Key.

Through PowerShell command I have copied "NessusAgent-8.1.0-x64.msi" in C drive already on 80 servers through server_list.txt. Now, trying to run the below command on those 80 servers passing the same server_list.txt.

msiexec /i NessusAgent-8.1.0-x64.msi NESSUS_SERVER="server name" NESSUS_KEY=NessusKey /qn

Any help would be appreciated.

Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • The problem is PowerShell's re-quoting of the arguments behind the scenes, which turns `NESSUS_SERVER="server name"` into `"NESSUS_SERVER=server name"` (argument _as a whole_ is double-quoted), which `msiexec` doesn't accept. Use `NESSUS_SERVER='"server name"'` or precede the arguments with `--%` (which has side effects, however) - see [this answer](https://stackoverflow.com/a/50868019/45375) to the linked duplicate. – mklement0 Nov 06 '20 at 19:38
  • @mklement0 I have tried as you said NESSUS_SERVER=' "server name" '. It didn't work. I tried to run the command through cmd manually, It only installs msi when I ran cmd through elevated privileges. So can you give me code to run the command through elevated cmd and then run the above command in it. – Rahul Chowdhury Nov 06 '20 at 21:07
  • You have spaces between `'` and `"`: remove them. – mklement0 Nov 06 '20 at 21:09
  • If you need elevation, run `Start-Process -Verb RunAs msiexec '...'`, in which case you don't need the quoting workaround- see the last section of the linked answer. – mklement0 Nov 06 '20 at 21:11
  • If these suggestions still don't help, you can create a _new_ question that shows an attempt based on these suggestions. – mklement0 Nov 06 '20 at 22:34

0 Answers0