Question Objet Com Volume Shadow Copy

Plus d'informations
il y a 16 ans 6 mois #5218 par BARTHE
Bonjour à tous,

Je cherche à utiliser VSS depuis powershell

Pour cela je me suis dirigé vers la recherche de l'objet Com VSS.

J'ai utilisé la fonction présente dans le livre Get-ProgID

et j'ai comme résultat
[code:1]
PS C:\Users\Administrateur\Desktop> Get-ProgID VSS

ProgID
VSMGMT.VssSnapshotMgmt.1
VCBRequestor.VmVssRequestor.1
Vss.VSSShellExt.1
Vss.VSSUI.1
VSS.VSSCoordinator.1
[/code:1]

j'ai donc continué par
[code:1]
$vss = New-Object -ComObject VSS.VSSCoordinator
$vss | Get-Member
][/code:1]
et j'obtient comme réponse

[code:1]
TypeName: System.__ComObject

Name MemberType Definition
----

CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType)
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
ToString Method System.String ToString()

[/code:1]

Je m'apperçoit qu'il n'y a pas l'identifiant de l'objet com apres TypeName: System.__ComObject

et que le nombre de méthode est limité

J'ai du faire une erreur quelque part...

Merci d'avance pour votre aide ;)<br><br>Message édité par: cyril.barthe, à: 29/08/09 14:21

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 16 ans 6 mois #5219 par Laurent Dardenne
Salut,
cyril.barthe écrit:

Je m'apperçoit qu'il n'y a pas l'identifiant de l'objet com apres TypeName: System.__ComObject

et que le nombre de méthode est limité

J'ai du faire une erreur quelque part...

Non je ne pense pas.
Le progID existe, mais ici pour un usage sous Win32.
Pour utiliser un objet COM sous Dotnet on a besoin d'un PIA (Primary interop Assembly).
Sous Visual Studio si on référence \&quot;Volume Shadow Copy Service 1.0 Type Library\&quot;, il crée un fichier Interop.VSS.dll.

Si Microsoft n'en propose pas il faut en générer un personnel.
Pour plus d'info, tu peux consulter le chapitre 5 de ce tutoriel .

Mais pour le moment je n'arrive pas à l'utiliser sous PS.<br><br>Message édité par: Laurent Dardenne, à: 31/08/09 11:29

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 16 ans 6 mois #5220 par BARTHE
Réponse de BARTHE sur le sujet Re:Objet Com Volume Shadow Copy
Merci à toi, je n'ai pas assez de recul en programmation (pas de recul du tout même) pour me lancer la dedans :laugh:

Je vais essayer de passer par la commande vssadmin.

Dommage je voulais jouer avec les objets com ;)

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 16 ans 6 mois #5221 par Laurent Dardenne
cyril.barthe écrit:

Merci à toi, je n'ai pas assez de recul en programmation (pas de recul du tout même) pour me lancer la dedans :laugh:

Oui je comprends. De mon coté en creusant un peu, j'arrive à ceci :
[code:1]
#Création d'une signature
sn.exe -k signature.snk
#Création de l'assembly à partir d'une librairie de type (COM)
TlbImp C:\WINDOWS\system32\vssvc.exe /out:g:\temp\Interop.VSS.dll /namespace:\&quot;Interop.VSS\&quot; /primary /keyfile:g:\temp\signature.snk /asmversion:1.0.0
#Ensuite copier le fichier dans le GAC
[/code:1]
Une fois le fichier interop généré et copié dans le GAC, on procéde ainsi:
[code:1]
[Reflection.Assembly]::LoadWithPartialName(\&quot;Interop.VSS\&quot;«»)

$Vss= New-object Vss.VSSCoordinatorClass
$vss
$vss|gm
[/code:1]

TypeName: VSS.VSSCoordinatorClass

Name MemberType Definition
----



AbortAllSnapshotsInProgress Method System.Void AbortAllSnapshotsInProgress()
AddToSnapshotSet Method System.Void AddToSnapshotSet(String pwszVolumeName, Guid ProviderId, Guid&amp; ...
BreakSnapshotSet Method System.Void BreakSnapshotSet(Guid SnapshotSetId)
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType)
DeleteSnapshots Method System.Void DeleteSnapshots(Guid SourceObjectId, _VSS_OBJECT_TYPE eSourceOb...
DoSnapshotSet Method System.Void DoSnapshotSet(Object pWriterCallback, IVssAsync&amp; ppAsync)
Equals Method System.Boolean Equals(Object obj)
ExposeSnapshot Method System.Void ExposeSnapshot(Guid SnapshotId, String wszPathFromRoot, Int32 l...
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetSnapshotProperties Method System.Void GetSnapshotProperties(Guid SnapshotId, _VSS_SNAPSHOT_PROP&amp; pProp)
GetType Method System.Type GetType()
ImportSnapshots Method System.Void ImportSnapshots(String bstrXMLSnapshotSet, IVssAsync&amp; ppAsync)
InitializeLifetimeService Method System.Object InitializeLifetimeService()
IsVolumeSnapshotted Method System.Void IsVolumeSnapshotted(Guid ProviderId, String pwszVolumeName, Int...
IsVolumeSupported Method System.Void IsVolumeSupported(Guid ProviderId, String pwszVolumeName, Int32...
Query Method System.Void Query(Guid QueriedObjectId, _VSS_OBJECT_TYPE eQueriedObjectType...
QueryProviders Method System.Void QueryProviders(IVssEnumObject&amp; ppenum)
RegisterProvider Method System.Void RegisterProvider(Guid pProviderId, Guid ClassId, String pwszPro...
RemountReadWrite Method System.Void RemountReadWrite(Guid SnapshotId, IVssAsync&amp; ppAsync)
SetContext Method System.Void SetContext(Int32 lContext)
SetWriterInstances Method System.Void SetWriterInstances(Int32 lWriterInstanceIdCount, Guid&amp; rgWriter...
StartSnapshotSet Method System.Void StartSnapshotSet(Guid&amp; pSnapshotSetId)
ToString Method System.String ToString()
UnregisterProvider Method System.Void UnregisterProvider(Guid ProviderId)
MSDN ScriptMethod System.Object MSDN();

Dernière étape, appeler une méthode :)<br><br>Message édité par: Laurent Dardenne, à: 29/08/09 18:59

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 16 ans 6 mois #5222 par Laurent Dardenne
En recherchant qq infos sur le sujet j'ai trouvé ceci :

Le sdk (ça c'est facile)
msdn.microsoft.com/en-us/library/bb968832(VS.85).aspx

AlphaVSS (source C#)
alphavss.codeplex.com/Release/ProjectRel...aspx?ReleaseId=21292
une doc sur VSS et AlphaVSS (code C#)
www.raysa.org/~lgele/TutoVSS/Tuto%20VSS.pdf

Projet démo (source VB .NET)
www.howtocode.net/software-development/n...adow-copies-from-net

Hobocopy ( source C++)
alt.pluralsight.com/wiki/default.aspx/Craig/HoboCopy.html

Mais cela nécessite d'y consacrer un peu de temps, et je ne suis pas sûr que cela soit utilisable sous PowerShell V1.
Je m'arrêterai donc là.<br><br>Message édité par: Laurent Dardenne, à: 29/08/09 19:12

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 16 ans 6 mois #5224 par Laurent Dardenne
Pour info, le SDK de VSS contient un programme d'exemple qui propose ces options, cela peut peut-être t'aider:

PS C:\Program Files\Microsoft\VSSSDK72\TestApps\vshadow\bin\debug-server&gt; .\vshadow.exe

VSHADOW.EXE 2.2 - Volume Shadow Copy sample client
Copyright (C) 2005 Microsoft Corporation. All rights reserved.


Usage:
VSHADOW [optional flags] [commands]

List of optional flags:
-? - Displays the usage screen
-p - Manages persistent shadow copies
-nw - Manages no-writer shadow copies
-ad - Creates differential HW shadow copies
-ap - Creates plex HW shadow copies
-scsf - Creates Shadow Copies for Shared Folders (Client Accessible)
-t={file.xml} - Transportable shadow set. Generates also the backup components doc.
-bc={file.xml} - Generates the backup components doc for non-transportable shadow set.
-wi={Writer Name} - Verify that a writer/component is included
-wx={Writer Name} - Exclude a writer/component from set creation or restore
-script={file.cmd} - SETVAR script creation
-exec={command} - Custom command executed after shadow creation, import or between break and make-it-write
-wait - Wait before program termination or between shadow set break and make-it-write
-tracing - Runs VSHADOW.EXE with enhanced diagnostics

List of commands:
{volume list} - Creates a shadow set on these volumes
-ws - List writer status
-wm - List writer summary metadata
-wm2 - List writer detailed metadata
-q - List all shadow copies in the system
-qx={SnapSetID} - List all shadow copies in this set
-s={SnapID} - List the shadow copy with the given ID
-da - Deletes all shadow copies in the system
-do={volume} - Deletes the oldest shadow of the specified volume
-dx={SnapSetID} - Deletes all shadow copies in this set
-ds={SnapID} - Deletes this shadow copy
-i={file.xml} - Transportable shadow copy import
-b={SnapSetID} - Break the given shadow set into read-only volumes
-bw={SnapSetID} - Break the shadow set into writable volumes
-el={SnapID},dir - Expose the shadow copy as a mount point
-el={SnapID},drive - Expose the shadow copy as a drive letter
-er={SnapID},share - Expose the shadow copy as a network share
-er={SnapID},share,path - Expose a child directory from the shadow copy as a share
-r={file.xml} - Restore based on a previously-generated Backup Components document
-rs={file.xml} - Simulated restore based on a previously-generated Backup Components doc
-revert={SnapID} - Revert a volume to the specified shadow copy

Examples:

- Non-persistent shadow copy creation on C: and D:
VSHADOW C: E:

- Persistent shadow copy creation on C: (with no writers)
VSHADOW -p -nw C:

- Transportable shadow copy creation on X:
VSHADOW -t=file1.xml X:

- Transportable shadow copy import
VSHADOW -i=file1.xml

- List all shadow copies in the system:
VSHADOW -q

Please see the README.DOC file for more details.

<br><br>Message édité par: Laurent Dardenne, à: 31/08/09 14:31

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.061 secondes
Propulsé par Kunena