Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Using VSS with powershell through COM

Reply
 
Old 04-16-2007   #1 (permalink)
christhorsen@gmail.com


 
 

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 SpecsSystem Spec
Old 04-17-2007   #2 (permalink)
christhorsen@gmail.com


 
 

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 SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Installing PowerShell dependent features on W2K8 with PowerShell CTP PowerShell
when run powershell script as windows service ,powershell fail PowerShell
Powershell Plus - Free for non commercial Use and Powershell Analyzer1.0 released PowerShell
Automatic PowerShell Error Parsing in PowerShell Analyzer and PowerShellPlus PowerShell
PowerShell Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46