'Concatenate multiple commands on powershell script
I'm trying to run multiple commands from a powershell script
The part of the script that execute commands
[String]$CommandToExecute = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "command 1;command2; (New-Object System.Net.WebClient).DownloadFile('https://site/file.exe','file.exe');Start-Process 'file.exe'"'
the command1 and 2 I'm being able to run it but when downloading the file I get
At C:\Users\Desktop\file.ps1:16 char:333
+ ... ktop\file.txt;"(New-Object System.Net.WebClient).DownloadFile('https:// ...
+ ~
Missing ')' in function parameter list.
At C:\Users\Desktop\file.ps1:9 char:29
+ Function script:Set-INFFile {
+ ~
Missing closing '}' in statement block or type definition.
At C:\Users\Desktop\file.ps1:17 char:2
+ )
+ ~
Unexpected token ')' in expression or statement.
At C:\Users\Desktop\file.ps1:46 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingEndParenthesisInFunctionParameterList
And I don't understand what may be the cause
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
