Reputation: 11
I've an issue running a Script in a windowsservercore:10.0.14393.206 image that is used to build a .NET project. I need to manually change the location of some .dll files from package to Web/Bin with a Powershell script but I get the error:
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
The script is as follows:
$srcdir = "packages";
$destdir = "Web\Bin";
md $destdir;
$files = (Get-ChildItem $srcdir -Recurse -Include *.dll*, *.lic*);
$files|foreach($_){
echo $_.Fullname;
Copy-Item -Path $_.Fullname -Destination ("$destdir" + "\" + "$_.Name") -Recurse;
}
Any ideas reagarding this?
Upvotes: 1
Views: 2231
Reputation: 37710
You have a few issues going on here. First it is much better to use Join-Path to build paths than to try to build them yourself. Second, there is no need to put double quotes around any of the variables when building the path. Third, if you are going to use the unneeded double quotes, yoou need a $() around the $_.Name to force the property to be accessed as opposed to the .TOString() function of the object. Here is an alternative way to do that line:
Copy-Item -Path $_.Fullname -Destination (Join-Path $destdir $_.Name) -Recurse;
Upvotes: 1