'Cannot execute PowerShell Script
ps1 with following content
Write-Output "Download Prerequisite Softwares"
$FolderName = "C:\Softwares\"
$VSCPlusPlusUri = 'https://download.visualstudio.microsoft.com/download/pr/d22ecb93-6eab-4ce1-89f3-97a816c55f04/37ED59A66699C0E5A7EBEEF7352D7C1C2ED5EDE7212950A1B0A8EE289AF4A95B/VC_redist.x64.exe'
if (Test-Path -Path $FolderName) {
Remove-Item $FolderName -Recurse -ErrorAction Ignore
} else {
New-Item $FolderName -ItemType Directory
Write-Output "1) Download and install Visual C++ Runtime"
Start-BitsTransfer –Source $VSCPlusPlusUri -Destination $FolderName
Start-Process 'C:\Softwares\VC_redist.x64.exe' -ArgumentList “/passive” -Wait -Passthru
}
When I execute command line by line (copy single line and paste into Windows PowerShell), it works well but I try to execute .\test.ps1 it throw error below
At C:\1.PowerShell\1.TPX-1418-WindowsServer2016\2.1-DownloadAndInstallVisualCplusPlus.ps1:13 char:23
+ ... Start-BitsTransfer –Source $VSCPlusPlusUri -Destination $FolderName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
At C:\1.PowerShell\1.TPX-1418-WindowsServer2016\2.1-DownloadAndInstallVisualCplusPlus.ps1:8 char:8
+ } else {
+ ~
Missing closing '}' in statement block or type definition.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
Please help me this case ! Thanks all
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
