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.
Related
Within a PowerShell script I need to do the following:
Execute the "SVN Copy Versions Items Here" RMB command for copying an earlier version of File A to a later version of File A in order to compare the before / after prior to a commit.
I know the full path of both files, and the paths / call look something like this:
$fromFile = C:\trunk\v100\fileA.txt
$toFile = C:\trunk\v200\fileA.txt
If I execute the following command:
svn copy $fromFile $toFile
I get the following error: svn: E155010: Path 'C:\trunk\v200\fileA.txt' is not a directory
I believe $fromFile and $toFile are both stored as text.
Any suggestions?
I was able to figure this out. Posting solution in the event anyone comes across the same issue. The error message displayed was a red herring - it has nothing to do with a directory.
Note: In my example, the $toFile had been added via a Subversion Add.
Resolved in the following manner:
svn revert $toFile
Remove-Item $toFile
svn copy $fromFile $toFile
It seems like if the file is present an error is thrown. The revert and remove calls fixed this.
I have downloaded some files with PSFTP from a SQL Server. The problem is that PSFTP changes the dates of creation/update and last modified of the files when downloading them in a local folder. For me it is important to keep the original dates. Is there any command to set/change it? Thanks
This is the script of the batch file
psftp.exe user#host -i xxx.ppk -b abc.scr
This is the scriptof the SCR file
cd /path remote folder
lcd path local folder
mget *.csv
exit
I'm not familiar with PSFTP and after looking at the docs I don't see any option to do this. However, you can use the -p flag of pscp to preserve dates and times.
See docs here.
(note it's a lower-case p, the other case is for specifying the port)
I’m trying to use AgeStore to remove some expired symbol files. I’ve written a Powershell script in which the AgeStore command works sometimes, but, not always.
For example, my symbol store contains symbol files dating back to 2010. I’d like to clean out the “expired” symbols because they are no longer needed. To that end, I use the -date command line argument to specify “-date=10-01-2010”. Additionally, I use the “-l” switch to force AgeStore to
Causes AgeStore not to delete any files, but merely to list all the
files that would be deleted if this same command were run without the
-l option.
Here’s a snippet of the script code that runs…
$AgeStore = "$DebuggingToolsPath\AgeStore"
$asArgs = "`"$SymbolStorePath`" -date=$CutoffDate -s -y "
if ($WhatIf.IsPresent) { $asArgs += "-l" }
# determine size of the symbol store before delete operation.
Write-Verbose ">> Calculating current size of $SymbolStorePath before deletion.`n" -Verbose
">> $SymbolStorePath currently uses {0:0,0.00} GB`n" -f (((Get-ChildItem -R $SymbolStorePath | measure-object length -Sum ).Sum / 1GB))
Write-Verbose ">> Please wait...processing`n`n" -Verbose
& $AgeStore $asArgs
When the above code runs, it returns the following output…
processing all files last accessed before 10-01-2010 12:00 AM
0 bytes would be deleted
The program 'RemoveOldDebugSymbols.ps1: PowerShell Script' has exited
with code 0 (0x0).
I have verified that there are symbol files with dates earlier than “10-01-2010” in the symbol store. I’ve subsequently tried the same experiment with a different cutoff date, “11-01-2015” and the output indicates that there are several files it would have deleted, but, not those that are from 2010. I’m at a loss as to what may cause the discrepancy.
Has anyone tried to delete symbol files from a symbol store using AgeStore? If so, have you run into this problem? How did you resolve it?
I’ve tried to resolve this many different ways using AgeStore. For the sake of moving forward with a project, I’ve decided to rewrite the script to use the SymStore command with a delete transaction. Basically, I created a list of the debug symbol transactions that should be removed and wrote a loop that iterates over the list and deletes each entry one at a time.
Hope this is helpful for anyone who runs into the same problems.
EDIT: Per request....I cannot post the entire script, but, I used the following code in a loop as a replacement for the AgeStore command.
$ssArgs = ".\symstore.exe del /i $SymbolEntryTransactionID /s `"$SymbolStorePath`""
Invoke-Expression $ssArgs
I am currently trying to convert a series of batch files to powershell scripts. I would like to run a compiler for the source files that exist in a directory, recursively. The compiler requires a long list of arguments. The catch is, I want the arguments to be variable so I can change them as needed. This is a typical call from the batch file (simplified for readability and length):
"C:\PICC Compilers\picc18.exe" --pass1
"C:\Src Files\somefile.c"
"-IC:\Include Files" "-IC:\Header
Files" -P
--runtime=default,+clear,+init,-keep,+download,+stackwarn,-config,+clib,-plib
--opt=default,+asm,-speed,+space,9 --warn=0 --debugger=realice -Blarge --double=24 --cp=16 -g --asmlist "--errformat=Error [%n] %f; %l.%c
%s" "--msgformat=Advisory[%n] %s" --OBJDIR="C:\Built Files"
"--warnformat=Warning [%n] %f; %l.%c %s"
This command executes fine when included in a batch file, but I start getting errors when I copy and paste the command into powershell. This is only my second day working with powershell, but I have developed with .NET in the past. I have managed to scrape together the following attempt:
$srcFiles = Get-ChildItem . -Recurse -Include "*.c"
$srcFiles | % {
$argList = "--pass1 " + $_.FullName;
$argList += "-IC:\Include Files -IC:\Header Files -P --runtime=default,+clear,+init,-keep,+download,+stackwarn,-config,+clib,-plib --opt=default,+asm,-speed,+space,9 --warn=0 --debugger=realice -Blarge --double=24 --cp=16 -g --asmlist '--errformat=Error [%n] %f; %l.%c %s' '--msgformat=Advisory[%n] %s' '--warnformat=Warning [%n] %f; %l.%c %s"
$argList += "--OBJDIR=" + $_.DirectoryName;
&"C:\PICC Compilers\picc18.exe" $argList }
I know that I probably have multiple issues with the above code, namely how to pass arguments and how I am dealing with the quotes in the argument list. Incorrect as it is, it should illustrate what I am trying to achieve. Any suggestions on where to start?
Calling command line applications from PowerShell might be really tricky. Several weeks ago #Jaykul wrote great blog post The problem with calling legacy/native apps from PowerShell where he describes gotchas which people will meet in this situations. And there is of course solution too ;)
edit - correct url
The article is no more available, so it's only possible to see that through web.archive.org - see cached article
Make $arglist an array instead of a string. A single string will always be passed as a single argument which is what you don't want here.
Similar to this question:
Get all files from VSS for a given date?
I am trying to write a script that get a VSS project tree for a specified label. I have this:
:: Path to the SS.exe command
set ss="C:\Program Files\Microsoft Visual SourceSafe\ss"
:: Path to the srcsafe.ini file for the repository
set SSDIR=\\Glopsvrfile01\VSS_Data
:: Path to the project root in VSS
set VSSRoot="$/Customers/MyCustomer/MyProject"
set /p version="Please enter a SourceSafe label: "
mkdir temp
:: vvv Here is the command vvv
%ss% get %VSSRoot% -Vl%version% -GLtemp -R
del /s /q temp\*.*
rmdir temp
and I am definitely passing in a valid label (V1.0.29) but it just comes back with
Version not found
Having tried it with a version labeled TempLabel, that works! Is it just the dots?
Does anyone know how to list all the labeled versions of a project on the command line?
-- Alistair
After spending couple of hours, finally I able to find the small glitch in your provided script.
Simple replace Vl with VL in the line below. Remaining is perfect.
%ss% get %VSSRoot% -Vl%version% -GLtemp -R
Enjoy!
Asif