I'm having difficulties with some commands in scriptblocks. The last line in the scriptblock is generating errors which appear to be due to double quotes. Any help would be great!![]()
The error:
At C:\temp\createcdnsite.ps1:23 char:261
+ ... My Website"}
+ ~~
The string is missing the terminator: ".
At C:\temp\createcdnsite.ps1:23 char:40
+ Invoke-Command -ComputerName $computer {set-WebConfiguration â?"Filter /Syste
m.W ...
+ ~
Missing closing '}' in statement block.
At C:\temp\createcdnsite.ps1:22 char:37
+ Foreach ($computer in $computerlist){
+ ~
Missing closing '}' in statement block.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
..here's the overall script
$sc = {
$pathtosite = "D:\website"
Add-WindowsFeature Web-Server,web-asp,web-basic-auth,web-windows-auth,web-mgmt-tools
Import-Module WebAdministration
New-Website -Name "My Website" –HostHeader "www.website.int" -PhysicalPath $pathtosite
set-WebConfiguration –Filter /System.WebServer/HttpErrors/Error[@StatusCode='404'] -Value @{PrefixLanguageFilePath="$Null"; Path="$pathtosite\FileNotFound.htm"} -PSPath IIS:\ -location "My Website"
}
$computerlist = Get-Content c:\temp\computerlist.txt
Foreach ($computer in $computerlist){
Invoke-Command -ComputerName $computer -ScriptBlock $sc
}