Question
Objet Com Volume Shadow Copy
- BARTHE
- Auteur du sujet
- Hors Ligne
- Membre junior
-
- Messages : 25
- Remerciements reçus 0
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
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
- Messages : 6311
- Remerciements reçus 68
cyril.barthe écrit:
Non je ne pense pas.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...
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 \"Volume Shadow Copy Service 1.0 Type Library\", 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.
- BARTHE
- Auteur du sujet
- Hors Ligne
- Membre junior
-
- Messages : 25
- Remerciements reçus 0
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.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
- Messages : 6311
- Remerciements reçus 68
Oui je comprends. De mon coté en creusant un peu, j'arrive à ceci :Merci à toi, je n'ai pas assez de recul en programmation (pas de recul du tout même) pour me lancer la dedans
[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:\"Interop.VSS\" /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(\"Interop.VSS\"«»)
$Vss= New-object Vss.VSSCoordinatorClass
$vss
$vss|gm
[/code:1]
Dernière étape, appeler une méthodeTypeName: VSS.VSSCoordinatorClass
Name MemberType Definition
----
AbortAllSnapshotsInProgress Method System.Void AbortAllSnapshotsInProgress()
AddToSnapshotSet Method System.Void AddToSnapshotSet(String pwszVolumeName, Guid ProviderId, Guid& ...
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& 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& pProp)
GetType Method System.Type GetType()
ImportSnapshots Method System.Void ImportSnapshots(String bstrXMLSnapshotSet, IVssAsync& 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& ppenum)
RegisterProvider Method System.Void RegisterProvider(Guid pProviderId, Guid ClassId, String pwszPro...
RemountReadWrite Method System.Void RemountReadWrite(Guid SnapshotId, IVssAsync& ppAsync)
SetContext Method System.Void SetContext(Int32 lContext)
SetWriterInstances Method System.Void SetWriterInstances(Int32 lWriterInstanceIdCount, Guid& rgWriter...
StartSnapshotSet Method System.Void StartSnapshotSet(Guid& pSnapshotSetId)
ToString Method System.String ToString()
UnregisterProvider Method System.Void UnregisterProvider(Guid ProviderId)
MSDN ScriptMethod System.Object MSDN();
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
- Messages : 6311
- Remerciements reçus 68
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.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
- Messages : 6311
- Remerciements reçus 68
<br><br>Message édité par: Laurent Dardenne, à: 31/08/09 14:31PS C:\Program Files\Microsoft\VSSSDK72\TestApps\vshadow\bin\debug-server> .\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.
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Objet Com Volume Shadow Copy