![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Using VSS with powershell through COM Has anyone had luck creating a VSS COM object inside Powershell? I'm not very familiar with VB and references and I haven't been able to figure out what I need to load in order to be able to run something like: PS> $vss = new-object -com VSSDatabase I've been able to figure out that the code I want to access is in ssapi.dll and that I might beable to use any one of the following: Interop.SourceSafeTypeLib.dll Microsoft.VisualStudio.SourceSafe.Interop SourceSafeTypeLib.VSSDatabase But my experimentations with [System.Reflection.Assembly]::LoadWithPartialName and new-object haven't worked out. Any help you can provide would be vastly appreciated. Thanks, --Chris |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Using VSS with powershell through COM On Apr 16, 12:32 pm, christhor...@gmail.com wrote: > Has anyone had luck creating a VSS COM object inside Powershell? > > I'm not very familiar with VB and references and I haven't been able > to figure out what I need to load in order to be able to run something > like: > > PS> $vss = new-object -com VSSDatabase > > I've been able to figure out that the code I want to access is in > ssapi.dll and that I might beable to use any one of the following: > > Interop.SourceSafeTypeLib.dll > Microsoft.VisualStudio.SourceSafe.Interop > SourceSafeTypeLib.VSSDatabase > > But my experimentations with > [System.Reflection.Assembly]::LoadWithPartialName and new-object > haven't worked out. > > Any help you can provide would be vastly appreciated. > > Thanks, > > --Chris I found how how to query the VSS database using code like the following: $VSSDatabase = new-object -com SourceSafe -strict $VSSDatabase.Open() $VSSProject = $VSSDatabase.VSSItem("$VSSPath") $VSSHash = @{} if ($ProductionObjects -ne $null) { foreach ($VSSFile in $VSSProject.Items()) { write-host "$($VSSFile.VersionNumber) $($VSSFile.Name)" } } In order to do a GET, you have to get the proper values for the VSSFLAG enumeration. To see the values, I went into Excel VBA and added a reference to "Microsoft SourceSafe 6.0 TypeLibrary" and used the Object Browser to look at the library and the VSSFlags enumeration. $g = $VSSDatabase.VSSItem("$/MyProject/MySubProject/Myfile.cmd") $g.Get([ref]"c:\a\MyFile2.cmd", $VSSFLAG_TIMEUP -bor $VSSFLAG_REPREPLACE) # VSSFlags Enumerations # These flags are used with Get # See: http://msdn2.microsoft.com/en-us/lib...es(vs.80).aspx $VSSFLAG_REPREPLACE = 128 # A flag that represents that writable files on the local computer are replaced. $VSSFLAG_TIMEUP = 12 # Timestamp uses the last check in time. $VSSFLAG_RECURSYES = 8192 # Indicates that a command should be recursive (act on an entire project tree). $VSSFLAG_FORCEDIRNO = 16384 # Used to override the working folder specifications. # We don't want to use these $VSSFLAG_TIMENOW = 4 # Timestamp uses the current time. This is the default. $VSSFLAG_TIMEMOD = 8 # Timestamp uses the last modified time. $VSSFLAG_RECURSNO = 4096 # Indicates that a command should not be recursive (act on an entire project tree). This is the default. $VSSFLAG_FORCEDIRYES = 32768 # Used to maintain the working folder settings. This is the default. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |