I get an error when running a powershell script on one of our VMs. The error is:
ERROR: The string starting:
At C:\iso\floppy\Blah.ps1:7
char:95
+ cinst VisualStudio2012Professional -packageParameters "/Features:'WebTools
SQL VCMFCLibraries <<<< ' "
is missing the terminator: '.
The line, as pasted straight from the script is:
cinst VisualStudio2012Professional -packageParameters "/Features:'WebTools SQL VCMFCLibraries ' "
I can't see an error at all, the terminators are all correct, and this line was working fine until a few days ago.
Hoping someone else can see the obvious.
Found the issue. Further up the script file I had added the line
choco sources add -n=Local -s='L:\Chocolatey Package Repository'
It should have been
choco sources add -n Local -s 'L:\Chocolatey Package Repository'
As well as being wrong, it turns out that the = screws up the quote parsing despite the fact that the quotes match up, leading to a weird error further down.
Thank you to everyone who commented, it helped.
Related
I have a simple system command to copy file from one folder to another:
my $cmd = "xcopy /Y c:\DBs\Support\db.bak c:\jenkins\workdir\sql-bak-files";
When I try to run the following system commands, all fails:
1. my $res = qx/$cmd/;
2. my $res = qx($cmd);
3. using back ticks
All tries returned the error: Error number -1, error message: "Bad file descriptor".
When trying to use system($cmd) the error was Error number 65280, error message: "No such file or directory".
This perl code is running via Jenkins (ver 2.190.1) and perl v5.26.0.
This problem started after migrating the code from mercurial to git, but I don't think it's related.
It worked before, but now always fail :(
A backslash has a special meaning in a Perl quoted string. It is used to escape the following character - to "turn off" any special meaning. If you want to use a backslash in a Perl quoted string, then you need to use another backslash to escape it.
my $cmd = 'xcopy /Y c:\\DBs\\Support\\db.bak c:\\jenkins\\workdir\\sql-bak-files';
Alternatively, Perl recognises forward slashes in Windows paths, so it might be easier to replace your code with this:
my $cmd = 'xcopy /Y c:/DBs/Support/db.bak c:/jenkins/workdir/sql-bak-files';
Note that in both cases I have replaced your double-quotes with single-quotes. This has no effect on your problem, but it seems strange to use double-quoted strings if you're not using any of their special characteristics (like the expansion of variables).
Update: To debug a problem like this, you can try printing the string.
$ perl -E'say "xcopy /Y c:\DBs\Support\db.bak c:\jenkins\workdir\sql-bak-files"'
xcopy /Y c:DBsSupportdb.bak c:jenkinsworkdirsql-bak-files
I have a problem with VSCode terminal that started with the latest version.
It might be a bug or just a setting that I have missed, therefore I want to ask you before I report it as a bug.
Version 1.19.3
Commit 7c4205b5c6e52a53b81c69d2b2dc8a627abaa0ba
Date 2018-01-25T10:36:34.867Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
I have a file with different functions that I just for Office365 administrative tasks.
I always open the file in VSCode and run it (F5) and then I call the functions from another file.
But with the latest VSCode upgrade, when I run the file I get these errors in the terminal window. The errors point to lines that I have commented out (#).
In every function I first have commented lines with explanations to every variable that I use, like this: #$UserName = the Name of the user.
If I remove the $ sign after the comment-char # then the error for that line disappears.
The issue is not that I dont use the proper comment-based help syntax.
It is the fact that I have commented out variables that I don't use and that raises an error when I run (F5) the file in VSCode.
Does anyone have an explanation to why I can't have #$Var in my code.
At C:\Users\anno\OneDrive för företag\Powershell\Script\Anslut_till_O365.ps1:44 char:3
+ #$UPN: anvnamn & epostadress
+ ~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name
character. Consider using ${} to delimit the name.
At C:\Users\anno\OneDrive för företag\Powershell\Script\Anslut_till_O365.ps1:45 char:3
+ #$Firstname: Förnamn
+ ~~~~~~~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name
character. Consider using ${} to delimit the name.
At C:\Users\anno\OneDrive för företag\Powershell\Script\Anslut_till_O365.ps1:46 char:3
+ #$Lastname: Efternamn
+ ~~~~~~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name
character. Consider using ${} to delimit the name.
At C:\Users\anno\OneDrive för företag\Powershell\Script\Anslut_till_O365.ps1:47 char:3
+ #$Title: Medlemsnr inkl filialnrâ,¬
+ ~~~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name
character. Consider using ${} to delimit the name.
Below is the the first lines in the function that the Error is complaining about.
Function CreateNewE1User {
#$UPN: anvnamn & epostadress
#$Firstname: Förnamn
#$Lastname: Efternamn
#$Title: Medlemsnr inkl filialnrEUR
#$Displaynamn: Visningsnamn (Kedja Ort (Butiksnamn), Förnamn Efternamn KEDJA
#$PWD: Tillfälligt lösenord
#param ($UPN,$Firstname,$Lastname,$Title,$Displaynamn,$PWD,$SMTP)
Param(
$UPN,
$Firstname,
$Lastname,
$Title,
$Displaynamn,
$PWD='Password01'
)
#skapa ny användare
New-MsolUser -UserPrincipalName $UPN -FirstName $Firstname -LastName $Lastname -Title $Title -DisplayName $Displaynamn -UsageLocation "SE" -PasswordNeverExpires $false
}
Adding my comment as an answer since it did work out for the OP.
Have you thought that this is an environment thing?
Meaning something has changed/gotten corrupted on your system.
I say this because, I've seen this happen and it has happened to me. Code runs fine on one system and fails on another,
I have that issue as we speak. Do you have another system to try.
As a follow on to your issue and my associated comment. My discovery was that the latest VSCode update updated the default Keybindings, thus causing a conflict with my custom user keybindings. Once I deleted my custom keybindings which conflicted with the new default keybindings all things returned to normal.
Moral of the story, pay attention to the VSCode updates and really read the ReadMe file. Especially if you are in the habit of customizations.
The issue you are having is the PowerShellEditorService. This is the engine used by the PowerShell extension in VS Code and is what the PS Integrated Terminal is run on.
I cannot duplicate the errors you are getting. I am on the latest release of VS Code (1.19.3) and the PS Extension (1.5.1). If you update and still get the issue you can submit it to the GitHub repo to find out why it may be doing that on your installation. My guess is it still parses the line even if you have it commented. If you block comment that whole section it will likely cause the engine to skip trying to parse each line.
gsutil -m cp -R 'gs://[BUCKET]/' 'C:/Users/[USER]/[FOLDER]'
will display the following error
[Errno 22] invalid mode ('ab') or filename: u'C:\\Users\\[USER]\\[FOLDER]\\\\[BUCKET]\\[FILE].gstmp'
I've tried changing the '/'s to '//' to '\' and '\' with no results whatsoever
So, after hours trying to find out this was happening.. it happened that the filenames had a character that can't be used in filenames in windows.. hope this helps if anybody else runs into this error.
I am trying to automate a procedure that uses SVN, and I am trying to teach myself PowerShell (and scripting) in the process.
I set up a PowerShell script that reads values for revision numbers and my folder path, like this:
$GetSVN = read-host "Enter the SVN folder path: "
$RevStart = read-host "Enter the starting revision: "
$RevEnd = read-host "Enter the ending revision: "
It then calls SVN and (tries to) pass the parameters.
Here's my problem: When I try to call SVN as follows:
& "c:\Program Files\TortoiseSVN\bin\svn.exe" "-log -r $RevStart`:$RevEnd $GetSVN"
I get the following message:
svn: E205000: Non-numeric limit argument given
svn: E200004: Could not convert 'og -r BASE:#### [SVN file path]' into a number
Okay, fine. I tried adding an extra space before "-log". But when I do that, here's what happens:
Unknown subcommand: ' -log -r BASE:#### [SVN file path]'
Huh?!? What's going on with this? I've tried various variations of this, all to no avail. I can't find an answer to this anywhere. Does anyone have any insight?
I am a newbie to PowerShell scripting, so feel free to answer as such.
Thanks in advance . . .
Your call is wrong, multiple parameters are grouped as one. Better and correct way to do it is this:
set-alias svn "c:\Program Files\TortoiseSVN\bin\svn.exe"
svn log -r $RevStart`:$RevEnd $GetSVN
Setting alias is cosmetics. The real problem were " placement.
I'm running latexdiff v 0.25 and when I attempt latexdiff-vc --svn -r "myFile with spaces.tex" I get the following command line output:
Working on myFile with spaces.tex svn: 'myFile' is not under version
control Running latexdiff 2 and only 2 non-option arguments required.
Write latexdiff -h to get help Something went wrong in latexdiff.
Deleting myFile with spaces.tex and abort
I'm assuming it's a bug where the right filename isn't passed correctly to svn. The command runs fine on names w/o spaces.
Does anyone know a workaround?
Assuming you are doing this manually, you may be able to use the 8.3 file name that you can get on the command line using dir /x.