PowerShell script exchange
Post Reply
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

I'm trying to set the recycle time on a copy job using the code below (I can't find a cmdlet anywhere), but it requires a 'CModifiedUserInfo' object to be passed. Any idea what the methods look like for that function or how I create the object?

Code: Select all

$CopyJob = Get-VBRJob -Name $CopyJobName
$CopyJobOptions = $CopyJob.Options
$CopyJobOptions.GenerationPolicy.SyncIntervalStartTime = "16:30:00"
$CopyJob.SetOptions($CopyOptions, $null)


Exception calling "SetOptions" with "2" argument(s): "Object reference not set to an instance of an object."
At line:4 char:5
+     $CopyJob.SetOptions($CopyOptions, $null)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException


$CopyJob.SetOptions

void SetOptions(Veeam.Backup.Model.CJobOptions jobOptions, Veeam.Backup.Model.CModifiedUserInfo initiator)
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by oleg.feoktistov »

Hi Robert,

In such cases usually the answer is held inside the method signature. So, there we see the full name of the needed class: Veeam.Backup.Model.CModifiedUserInfo (namespace + class name). If you go to this class and access it with Powerhell ISE or VS Code with Powershell extension, Intellisense will display hints on class members :

Code: Select all

[Veeam.Backup.Model.CModifiedUserInfo]:: # here the class members should appear
I would probably go with one of these options:

Code: Select all

[Veeam.Backup.Model.CModifiedUserInfo]::CurrentWinUser
[Veeam.Backup.Model.CModifiedUserInfo]::CreateForPowershell()
But did you try using Set-VBRJobOptions cmdlet instead?

Thanks,
Oleg
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

Thanks Oleg. I've managed to find the route through using your suggested 'Set-VBRJobOptions'.

Regarding exposing the methods, the command you gave is invalid. If I use the command below, those methods that are clearly part of the oject still don't appear in the list?

Code: Select all


PS U:\WindowsPowerShell\Powershell Projects\Veeam Utilities> [Veeam.Backup.Model.CModifiedUserInfo] | get-member -force



   TypeName: System.RuntimeType

Name                           MemberType   Definition
----                           ----------   ----------
pstypenames                    CodeProperty System.Collections.ObjectModel.Collection`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] pstypenames{get=PSTypeNames;}
psadapted                      MemberSet    psadapted {Module, Assembly, TypeHandle, DeclaringMethod, BaseType, UnderlyingSystemType, FullName, AssemblyQualifiedName, Namespace, GUID, IsEnum, GenericParameterAttributes, I...
psbase                         MemberSet    psbase {Module, Assembly, TypeHandle, DeclaringMethod, BaseType, UnderlyingSystemType, FullName, AssemblyQualifiedName, Namespace, GUID, IsEnum, GenericParameterAttributes, IsSe...
psextended                     MemberSet    psextended {}
psobject                       MemberSet    psobject {Members, Properties, Methods, ImmediateBaseObject, BaseObject, TypeNames, get_Members, get_Properties, get_Methods, get_ImmediateBaseObject, get_BaseObject, ToString, ...
AsType                         Method       type AsType()
Clone                          Method       System.Object Clone(), System.Object ICloneable.Clone()
Equals                         Method       bool Equals(System.Object obj), bool Equals(type o), bool _MemberInfo.Equals(System.Object other), bool _Type.Equals(System.Object other), bool _Type.Equals(type o)
FindInterfaces                 Method       type[] FindInterfaces(System.Reflection.TypeFilter filter, System.Object filterCriteria), type[] _Type.FindInterfaces(System.Reflection.TypeFilter filter, System.Object filterCr...
FindMembers                    Method       System.Reflection.MemberInfo[] FindMembers(System.Reflection.MemberTypes memberType, System.Reflection.BindingFlags bindingAttr, System.Reflection.MemberFilter filter, System.Ob... 
GetArrayRank                   Method       int GetArrayRank(), int _Type.GetArrayRank()
GetConstructor                 Method       System.Reflection.ConstructorInfo GetConstructor(System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention... 
GetConstructors                Method       System.Reflection.ConstructorInfo[] GetConstructors(System.Reflection.BindingFlags bindingAttr), System.Reflection.ConstructorInfo[] GetConstructors(), System.Reflection.Constru...
GetCustomAttributes            Method       System.Object[] GetCustomAttributes(bool inherit), System.Object[] GetCustomAttributes(type attributeType, bool inherit), System.Object[] ICustomAttributeProvider.GetCustomAttri...
GetCustomAttributesData        Method       System.Collections.Generic.IList[System.Reflection.CustomAttributeData] GetCustomAttributesData()
GetDeclaredEvent               Method       System.Reflection.EventInfo GetDeclaredEvent(string name)
GetDeclaredField               Method       System.Reflection.FieldInfo GetDeclaredField(string name)
GetDeclaredMethod              Method       System.Reflection.MethodInfo GetDeclaredMethod(string name)
GetDeclaredMethods             Method       System.Collections.Generic.IEnumerable[System.Reflection.MethodInfo] GetDeclaredMethods(string name)
GetDeclaredNestedType          Method       System.Reflection.TypeInfo GetDeclaredNestedType(string name)
GetDeclaredProperty            Method       System.Reflection.PropertyInfo GetDeclaredProperty(string name)
GetDefaultMembers              Method       System.Reflection.MemberInfo[] GetDefaultMembers(), System.Reflection.MemberInfo[] _Type.GetDefaultMembers()
GetElementType                 Method       type GetElementType(), type _Type.GetElementType()
GetEnumName                    Method       string GetEnumName(System.Object value)
GetEnumNames                   Method       string[] GetEnumNames()
GetEnumUnderlyingType          Method       type GetEnumUnderlyingType()
GetEnumValues                  Method       array GetEnumValues()
GetEvent                       Method       System.Reflection.EventInfo GetEvent(string name, System.Reflection.BindingFlags bindingAttr), System.Reflection.EventInfo GetEvent(string name), System.Reflection.EventInfo _Ty...
GetEvents                      Method       System.Reflection.EventInfo[] GetEvents(System.Reflection.BindingFlags bindingAttr), System.Reflection.EventInfo[] GetEvents(), System.Reflection.EventInfo[] _Type.GetEvents(), ... 
GetField                       Method       System.Reflection.FieldInfo GetField(string name, System.Reflection.BindingFlags bindingAttr), System.Reflection.FieldInfo GetField(string name), System.Reflection.FieldInfo _Ty...
GetFields                      Method       System.Reflection.FieldInfo[] GetFields(System.Reflection.BindingFlags bindingAttr), System.Reflection.FieldInfo[] GetFields(), System.Reflection.FieldInfo[] _Type.GetFields(Sys...
GetGenericArguments            Method       type[] GetGenericArguments()
GetGenericParameterConstraints Method       type[] GetGenericParameterConstraints()
GetGenericTypeDefinition       Method       type GetGenericTypeDefinition()
GetHashCode                    Method       int GetHashCode(), int _MemberInfo.GetHashCode(), int _Type.GetHashCode()
GetIDsOfNames                  Method       void _MemberInfo.GetIDsOfNames([ref] guid riid, System.IntPtr rgszNames, uint32 cNames, uint32 lcid, System.IntPtr rgDispId), void _Type.GetIDsOfNames([ref] guid riid, System.In... 
GetInterface                   Method       type GetInterface(string fullname, bool ignoreCase), type GetInterface(string name), type _Type.GetInterface(string name, bool ignoreCase), type _Type.GetInterface(string name)     
GetInterfaceMap                Method       System.Reflection.InterfaceMapping GetInterfaceMap(type ifaceType), System.Reflection.InterfaceMapping _Type.GetInterfaceMap(type interfaceType)
GetInterfaces                  Method       type[] GetInterfaces(), type[] _Type.GetInterfaces()
GetMember                      Method       System.Reflection.MemberInfo[] GetMember(string name, System.Reflection.MemberTypes type, System.Reflection.BindingFlags bindingAttr), System.Reflection.MemberInfo[] GetMember(s... 
GetMembers                     Method       System.Reflection.MemberInfo[] GetMembers(System.Reflection.BindingFlags bindingAttr), System.Reflection.MemberInfo[] GetMembers(), System.Reflection.MemberInfo[] _Type.GetMembe...
GetMethod                      Method       System.Reflection.MethodInfo GetMethod(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvent...
GetMethods                     Method       System.Reflection.MethodInfo[] GetMethods(System.Reflection.BindingFlags bindingAttr), System.Reflection.MethodInfo[] GetMethods(), System.Reflection.MethodInfo[] _Type.GetMetho...
GetNestedType                  Method       type GetNestedType(string fullname, System.Reflection.BindingFlags bindingAttr), type GetNestedType(string name), type _Type.GetNestedType(string name, System.Reflection.Binding... 
GetNestedTypes                 Method       type[] GetNestedTypes(System.Reflection.BindingFlags bindingAttr), type[] GetNestedTypes(), type[] _Type.GetNestedTypes(System.Reflection.BindingFlags bindingAttr), type[] _Type...
GetObjectData                  Method       void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context), void ISerializable.GetObjectData(System.Runtime.S...
GetProperties                  Method       System.Reflection.PropertyInfo[] GetProperties(System.Reflection.BindingFlags bindingAttr), System.Reflection.PropertyInfo[] GetProperties(), System.Reflection.PropertyInfo[] _T...
GetProperty                    Method       System.Reflection.PropertyInfo GetProperty(string name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, type returnType, type[] types, System.Reflec...
GetType                        Method       type GetType(), type _MemberInfo.GetType(), type _Type.GetType()
GetTypeInfo                    Method       void _MemberInfo.GetTypeInfo(uint32 iTInfo, uint32 lcid, System.IntPtr ppTInfo), void _Type.GetTypeInfo(uint32 iTInfo, uint32 lcid, System.IntPtr ppTInfo), System.Reflection.Typ...
GetTypeInfoCount               Method       void _MemberInfo.GetTypeInfoCount([ref] uint32 pcTInfo), void _Type.GetTypeInfoCount([ref] uint32 pcTInfo)
get_Assembly                   Method       System.Reflection.Assembly get_Assembly(), System.Reflection.Assembly _Type.get_Assembly()
get_AssemblyQualifiedName      Method       string get_AssemblyQualifiedName(), string _Type.get_AssemblyQualifiedName()
get_Attributes                 Method       System.Reflection.TypeAttributes get_Attributes(), System.Reflection.TypeAttributes _Type.get_Attributes()
get_BaseType                   Method       type get_BaseType(), type _Type.get_BaseType()
get_ContainsGenericParameters  Method       bool get_ContainsGenericParameters()
get_CustomAttributes           Method       System.Collections.Generic.IEnumerable[System.Reflection.CustomAttributeData] get_CustomAttributes()
get_DeclaredConstructors       Method       System.Collections.Generic.IEnumerable[System.Reflection.ConstructorInfo] get_DeclaredConstructors()
get_DeclaredEvents             Method       System.Collections.Generic.IEnumerable[System.Reflection.EventInfo] get_DeclaredEvents()
get_DeclaredFields             Method       System.Collections.Generic.IEnumerable[System.Reflection.FieldInfo] get_DeclaredFields()
get_DeclaredMembers            Method       System.Collections.Generic.IEnumerable[System.Reflection.MemberInfo] get_DeclaredMembers()
get_DeclaredMethods            Method       System.Collections.Generic.IEnumerable[System.Reflection.MethodInfo] get_DeclaredMethods()
get_DeclaredNestedTypes        Method       System.Collections.Generic.IEnumerable[System.Reflection.TypeInfo] get_DeclaredNestedTypes()
get_DeclaredProperties         Method       System.Collections.Generic.IEnumerable[System.Reflection.PropertyInfo] get_DeclaredProperties()
get_DeclaringMethod            Method       System.Reflection.MethodBase get_DeclaringMethod()
get_DeclaringType              Method       type get_DeclaringType(), type _MemberInfo.get_DeclaringType(), type _Type.get_DeclaringType()
get_FullName                   Method       string get_FullName(), string _Type.get_FullName()
get_GenericParameterAttributes Method       System.Reflection.GenericParameterAttributes get_GenericParameterAttributes()
get_GenericParameterPosition   Method       int get_GenericParameterPosition()
get_GenericTypeArguments       Method       type[] get_GenericTypeArguments()
get_GenericTypeParameters      Method       type[] get_GenericTypeParameters()
get_GUID                       Method       guid get_GUID(), guid _Type.get_GUID()
get_HasElementType             Method       bool get_HasElementType(), bool _Type.get_HasElementType()
get_ImplementedInterfaces      Method       System.Collections.Generic.IEnumerable[type] get_ImplementedInterfaces()
get_IsAbstract                 Method       bool get_IsAbstract(), bool _Type.get_IsAbstract()
get_IsAnsiClass                Method       bool get_IsAnsiClass(), bool _Type.get_IsAnsiClass()
get_IsArray                    Method       bool get_IsArray(), bool _Type.get_IsArray()
get_IsAutoClass                Method       bool get_IsAutoClass(), bool _Type.get_IsAutoClass()
get_IsAutoLayout               Method       bool get_IsAutoLayout(), bool _Type.get_IsAutoLayout()
get_IsByRef                    Method       bool get_IsByRef(), bool _Type.get_IsByRef()
get_IsClass                    Method       bool get_IsClass(), bool _Type.get_IsClass()
get_IsCOMObject                Method       bool get_IsCOMObject(), bool _Type.get_IsCOMObject()
get_IsConstructedGenericType   Method       bool get_IsConstructedGenericType()
get_IsContextful               Method       bool get_IsContextful(), bool _Type.get_IsContextful()
get_IsEnum                     Method       bool get_IsEnum(), bool _Type.get_IsEnum()
get_IsExplicitLayout           Method       bool get_IsExplicitLayout(), bool _Type.get_IsExplicitLayout()
get_IsGenericParameter         Method       bool get_IsGenericParameter()
get_IsGenericType              Method       bool get_IsGenericType()
get_IsGenericTypeDefinition    Method       bool get_IsGenericTypeDefinition()
get_IsImport                   Method       bool get_IsImport(), bool _Type.get_IsImport()
get_IsInterface                Method       bool get_IsInterface(), bool _Type.get_IsInterface()
get_IsLayoutSequential         Method       bool get_IsLayoutSequential(), bool _Type.get_IsLayoutSequential()
get_IsMarshalByRef             Method       bool get_IsMarshalByRef(), bool _Type.get_IsMarshalByRef()
get_IsNested                   Method       bool get_IsNested()
get_IsNestedAssembly           Method       bool get_IsNestedAssembly(), bool _Type.get_IsNestedAssembly()
get_IsNestedFamANDAssem        Method       bool get_IsNestedFamANDAssem(), bool _Type.get_IsNestedFamANDAssem()
get_IsNestedFamily             Method       bool get_IsNestedFamily(), bool _Type.get_IsNestedFamily()
get_IsNestedFamORAssem         Method       bool get_IsNestedFamORAssem(), bool _Type.get_IsNestedFamORAssem()
get_IsNestedPrivate            Method       bool get_IsNestedPrivate(), bool _Type.get_IsNestedPrivate()
get_IsNestedPublic             Method       bool get_IsNestedPublic(), bool _Type.get_IsNestedPublic()
get_IsNotPublic                Method       bool get_IsNotPublic(), bool _Type.get_IsNotPublic()
get_IsPointer                  Method       bool get_IsPointer(), bool _Type.get_IsPointer()
get_IsPrimitive                Method       bool get_IsPrimitive(), bool _Type.get_IsPrimitive()
get_IsPublic                   Method       bool get_IsPublic(), bool _Type.get_IsPublic()
get_IsSealed                   Method       bool get_IsSealed(), bool _Type.get_IsSealed()
get_IsSecurityCritical         Method       bool get_IsSecurityCritical()
get_IsSecuritySafeCritical     Method       bool get_IsSecuritySafeCritical()
get_IsSecurityTransparent      Method       bool get_IsSecurityTransparent()
get_IsSerializable             Method       bool get_IsSerializable(), bool _Type.get_IsSerializable()
get_IsSpecialName              Method       bool get_IsSpecialName(), bool _Type.get_IsSpecialName()
get_IsUnicodeClass             Method       bool get_IsUnicodeClass(), bool _Type.get_IsUnicodeClass()
get_IsValueType                Method       bool get_IsValueType(), bool _Type.get_IsValueType()
get_IsVisible                  Method       bool get_IsVisible()
get_MemberType                 Method       System.Reflection.MemberTypes get_MemberType(), System.Reflection.MemberTypes _MemberInfo.get_MemberType(), System.Reflection.MemberTypes _Type.get_MemberType()
get_MetadataToken              Method       int get_MetadataToken()
get_Module                     Method       System.Reflection.Module get_Module(), System.Reflection.Module _Type.get_Module()
get_Name                       Method       string get_Name(), string _MemberInfo.get_Name(), string _Type.get_Name()
get_Namespace                  Method       string get_Namespace(), string _Type.get_Namespace()
get_ReflectedType              Method       type get_ReflectedType(), type _MemberInfo.get_ReflectedType(), type _Type.get_ReflectedType()
get_StructLayoutAttribute      Method       System.Runtime.InteropServices.StructLayoutAttribute get_StructLayoutAttribute()
get_TypeHandle                 Method       System.RuntimeTypeHandle get_TypeHandle(), System.RuntimeTypeHandle _Type.get_TypeHandle()
get_TypeInitializer            Method       System.Reflection.ConstructorInfo get_TypeInitializer(), System.Reflection.ConstructorInfo _Type.get_TypeInitializer()
get_UnderlyingSystemType       Method       type get_UnderlyingSystemType(), type _Type.get_UnderlyingSystemType(), type IReflect.get_UnderlyingSystemType()
Invoke                         Method       void _MemberInfo.Invoke(uint32 dispIdMember, [ref] guid riid, uint32 lcid, int16 wFlags, System.IntPtr pDispParams, System.IntPtr pVarResult, System.IntPtr pExcepInfo, System.In...
InvokeMember                   Method       System.Object InvokeMember(string name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System....
IsAssignableFrom               Method       bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo), bool IsAssignableFrom(type c), bool _Type.IsAssignableFrom(type c)
IsDefined                      Method       bool IsDefined(type attributeType, bool inherit), bool ICustomAttributeProvider.IsDefined(type attributeType, bool inherit), bool _MemberInfo.IsDefined(type attributeType, bool ...
IsEnumDefined                  Method       bool IsEnumDefined(System.Object value)
IsEquivalentTo                 Method       bool IsEquivalentTo(type other)
IsInstanceOfType               Method       bool IsInstanceOfType(System.Object o), bool _Type.IsInstanceOfType(System.Object o)
IsSubclassOf                   Method       bool IsSubclassOf(type type), bool _Type.IsSubclassOf(type c)
MakeArrayType                  Method       type MakeArrayType(), type MakeArrayType(int rank)
MakeByRefType                  Method       type MakeByRefType()
MakeGenericType                Method       type MakeGenericType(Params type[] instantiation)
MakePointerType                Method       type MakePointerType()
ToString                       Method       string ToString(), string _MemberInfo.ToString(), string _Type.ToString()
Assembly                       Property     System.Reflection.Assembly Assembly {get;}
AssemblyQualifiedName          Property     string AssemblyQualifiedName {get;}
Attributes                     Property     System.Reflection.TypeAttributes Attributes {get;}
BaseType                       Property     type BaseType {get;}
ContainsGenericParameters      Property     bool ContainsGenericParameters {get;}
CustomAttributes               Property     System.Collections.Generic.IEnumerable[System.Reflection.CustomAttributeData] CustomAttributes {get;}
DeclaredConstructors           Property     System.Collections.Generic.IEnumerable[System.Reflection.ConstructorInfo] DeclaredConstructors {get;}
DeclaredEvents                 Property     System.Collections.Generic.IEnumerable[System.Reflection.EventInfo] DeclaredEvents {get;}
DeclaredFields                 Property     System.Collections.Generic.IEnumerable[System.Reflection.FieldInfo] DeclaredFields {get;}
DeclaredMembers                Property     System.Collections.Generic.IEnumerable[System.Reflection.MemberInfo] DeclaredMembers {get;}
DeclaredMethods                Property     System.Collections.Generic.IEnumerable[System.Reflection.MethodInfo] DeclaredMethods {get;}
DeclaredNestedTypes            Property     System.Collections.Generic.IEnumerable[System.Reflection.TypeInfo] DeclaredNestedTypes {get;}
DeclaredProperties             Property     System.Collections.Generic.IEnumerable[System.Reflection.PropertyInfo] DeclaredProperties {get;}
DeclaringMethod                Property     System.Reflection.MethodBase DeclaringMethod {get;}
DeclaringType                  Property     type DeclaringType {get;}
FullName                       Property     string FullName {get;}
GenericParameterAttributes     Property     System.Reflection.GenericParameterAttributes GenericParameterAttributes {get;}
GenericParameterPosition       Property     int GenericParameterPosition {get;}
GenericTypeArguments           Property     type[] GenericTypeArguments {get;}
GenericTypeParameters          Property     type[] GenericTypeParameters {get;}
GUID                           Property     guid GUID {get;}
HasElementType                 Property     bool HasElementType {get;}
ImplementedInterfaces          Property     System.Collections.Generic.IEnumerable[type] ImplementedInterfaces {get;}
IsAbstract                     Property     bool IsAbstract {get;}
IsAnsiClass                    Property     bool IsAnsiClass {get;}
IsArray                        Property     bool IsArray {get;}
IsAutoClass                    Property     bool IsAutoClass {get;}
IsAutoLayout                   Property     bool IsAutoLayout {get;}
IsByRef                        Property     bool IsByRef {get;}
IsClass                        Property     bool IsClass {get;}
IsCOMObject                    Property     bool IsCOMObject {get;}
IsConstructedGenericType       Property     bool IsConstructedGenericType {get;}
IsContextful                   Property     bool IsContextful {get;}
IsEnum                         Property     bool IsEnum {get;}
IsExplicitLayout               Property     bool IsExplicitLayout {get;}
IsGenericParameter             Property     bool IsGenericParameter {get;}
IsGenericType                  Property     bool IsGenericType {get;}
IsGenericTypeDefinition        Property     bool IsGenericTypeDefinition {get;}
IsImport                       Property     bool IsImport {get;}
IsInterface                    Property     bool IsInterface {get;}
IsLayoutSequential             Property     bool IsLayoutSequential {get;}
IsMarshalByRef                 Property     bool IsMarshalByRef {get;}
IsNested                       Property     bool IsNested {get;}
IsNestedAssembly               Property     bool IsNestedAssembly {get;}
IsNestedFamANDAssem            Property     bool IsNestedFamANDAssem {get;}
IsNestedFamily                 Property     bool IsNestedFamily {get;}
IsNestedFamORAssem             Property     bool IsNestedFamORAssem {get;}
IsNestedPrivate                Property     bool IsNestedPrivate {get;}
IsNestedPublic                 Property     bool IsNestedPublic {get;}
IsNotPublic                    Property     bool IsNotPublic {get;}
IsPointer                      Property     bool IsPointer {get;}
IsPrimitive                    Property     bool IsPrimitive {get;}
IsPublic                       Property     bool IsPublic {get;}
IsSealed                       Property     bool IsSealed {get;}
IsSecurityCritical             Property     bool IsSecurityCritical {get;}
IsSecuritySafeCritical         Property     bool IsSecuritySafeCritical {get;}
IsSecurityTransparent          Property     bool IsSecurityTransparent {get;}
IsSerializable                 Property     bool IsSerializable {get;}
IsSpecialName                  Property     bool IsSpecialName {get;}
IsUnicodeClass                 Property     bool IsUnicodeClass {get;}
IsValueType                    Property     bool IsValueType {get;}
IsVisible                      Property     bool IsVisible {get;}
MemberType                     Property     System.Reflection.MemberTypes MemberType {get;}
MetadataToken                  Property     int MetadataToken {get;}
Module                         Property     System.Reflection.Module Module {get;}
Name                           Property     string Name {get;}
Namespace                      Property     string Namespace {get;}
ReflectedType                  Property     type ReflectedType {get;}
StructLayoutAttribute          Property     System.Runtime.InteropServices.StructLayoutAttribute StructLayoutAttribute {get;}
TypeHandle                     Property     System.RuntimeTypeHandle TypeHandle {get;}
TypeInitializer                Property     System.Reflection.ConstructorInfo TypeInitializer {get;}
UnderlyingSystemType           Property     type UnderlyingSystemType {get;}

oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by oleg.feoktistov »

Hi Robert,

They don't appear in the list, because you called Get-Member on RuntimeType class, not on CModifiedUserInfo. Long story short, it means you rendered common properties and methods, which can describe or act on any class. But not those implemented in a particular class.

Here is the way you can obtain the list of implemented methods for a particular class:

Code: Select all

[Veeam.Backup.Model.CModifiedUserInfo].DeclaredMethods | select Name
Thanks,
Oleg
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

Thanks again Oleg. I finally managed to get the Intellisense working in VS, but it was extremely intermittent. I suspect it has something to do with my username document locations being redirected to a file server which is hanging off the end of a VPN connection.

That's still a useful command to know though. I'm more used to working with PHP which is capable of dynamically dumping object information. I think I need to write an equivalent tool in Powershell so I can easily see what buried properties the Veeam cmdlets are returning.

Cheers, Rob.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by oleg.feoktistov »

Have never worked with PHP, but get it. I think the main problem with writing such a tool in Powershell is that we would need to actually have something in cmdlet output to then see what is the object type etc. The way I could think of that we can query it without instantiating or decompiling anything would be to launch an extended search across .NET namespaces based on cmdlet noun notation (e.g. take VBRComputerBackupJob from Get-VBRComputerBackupJob). Since the objects our cmdlets return have either VBR*, C* or VSB* prefixes (rarely it is some boolean or datetime value), they could be validated with this approach. Then you can simply obtain their properties and methods with the code above. Thanks!
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

It was more about expanding out the properties of objects, in the first instance. For example, Get-VBRJob returns huge amounts of information, but the command below only exposes the first level. My Object dumper would expose all levels....

Code: Select all

$job = get-vbrjob -name DEV_WEEKLY_AUTOMIC_BACKUP

$job | Format-List

LogNameMainPart              : DEV_WEEKLY_AUTOMIC_BACKUP
FreeBackupImpl               :
IsFree                       : False
UserCryptoKey                :
Uid                          : e63b6619-a58d-4c2d-96b8-db986a05cbb2
Id                           : e63b6619-a58d-4c2d-96b8-db986a05cbb2
Info                         : Veeam.Backup.Model.CDbBackupJobInfo
JobType                      : Backup
SourceType                   : VDDK
JobTargetType                : Backup
TargetType                   : Other
TypeToString                 : VMware Backup
Description                  : Dev Weekly Automic  backup
                               SQL Servers backup system disk only
Name                         : DEV_WEEKLY_AUTOMIC_BACKUP
BackupPlatform               : EVmware
TargetHostId                 : 00000000-0000-0000-0000-000000000000
TargetDir                    : ddboost://UKDCGDDM01.uk.randomhouse.com:VEEAM_DCGDDM01_AUTOMIC_REPOSITORY@/
TargetFile                   : DEV_WEEKLY_AUTOMIC_BACKUP
Options                      : Veeam.Backup.Model.CJobOptions
IsContinuous                 : False
BackupPolicyTag              :
NameWithDescription          : DEV_WEEKLY_AUTOMIC_BACKUP (Dev Weekly Automic  backup SQL Servers backup system disk
                               only)
SqlEnabled                   : False
OracleEnabled                : False
PostgreSqlEnabled            : False
ParentJobId                  :
ParentScheduleId             :
Usn                          : 182107647
PolicyJobId                  : 00000000-0000-0000-0000-000000000000
IsCdpReplica                 : False
HvReplicaTargetOptions       : Veeam.Backup.Model.CDomHvReplicaTargetOptions
BackupStorageOptions         : Veeam.Backup.Model.CDomBackupStorageOptions
BackupTargetOptions          : Veeam.Backup.Model.CDomBackupTargetOptions
HvSourceOptions              : Veeam.Backup.Model.CDomHvSourceOptions
NotificationOptions          : Veeam.Backup.Model.CDomNotificationOptions
JobScriptCommand             : Veeam.Backup.Model.CDomJobScriptCommand
VcdReplicaOptions            : Veeam.Backup.Model.CDomVcdReplicaOptions
ViReplicaTargetOptions       : Veeam.Backup.Model.CDomViReplicaTargetOptions
CloudReplicaTargetOptions    : Veeam.Backup.Model.CDomCloudReplicaTargetOptions
ViSourceOptions              : Veeam.Backup.Model.CDomViSourceOptions
VssOptions                   : VssSnapshotOptions: [Enabled: [True], ApplicationProcessingEnabled: [True],
                               IgnoreErrors: [False], IsCopyOnly: [False], UsePersistentGuestAgent: [False]],
                               WinGuestFSIndexingOptions: [Type: [None]], LinGuestFSIndexingOptions: [Type: [None]],
                               SqlBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob],
                               BackupLogsFrequencyMin: [15], UseDbBackupRetention: [True], RetainDays: [15],
                               ProxyAutoSelect: [True]FailJobOnDbAbsenceOrBackupImpossibility: [False]],
                               ExchangeBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob]],
                               WinCredsId: [1ed05a01-9163-4245-acee-dda1158873f0], LinCredsId:
                               [00000000-0000-0000-0000-000000000000], Old Properties: [Enabled: [True], IgnoreErrors:
                               [False], GuestFSIndexingType: [None], IncludedIndexingFolders: [],
                               ExcludedIndexingFolders: [], LinGuestFSIndexingType: [None],
                               LinIncludedIndexingFolders: [], LinExcludedIndexingFolders: [], IsFirstUsage: [True]]
ScheduleOptions              : Start time: [30/10/2021 08:30:00], Latest run time: [25/10/2021 12:33:04], Timeout for
                               backup completion: [180min], Next run time: [], Retry times on failure: [3], Retry
                               timeout: [10 min], Daily options: [Enabled: True, DayNumberInMonth: SelectedDays, Days:
                               Saturday]
IsChildJob                   : False
IsRunning                    : False
IsIdle                       : False
IsScheduleEnabled            : True
SourceProxyAutoDetect        : True
IsDeleted                    : False
IsInitialReplica             : False
IsMappingReplica             : False
IsEpPolicy                   : False
IsBackupPolicy               : False
IsBackup                     : True
IsBackupSync                 : False
IsBackupCopy                 : False
IsTapeCopy                   : False
IsStorageCopy                : False
IsPluginBackupCopy           : False
IsBackupCopySimpleMode       : False
IsLogBackupCopy              : False
IsWorkerJob                  : False
IsLogBackupCopyWorkerJob     : False
IsChildWorkerJob             : False
IsPolicyJob                  : False
IsSnapshotReplica            : False
IsLegacyReplica              : False
IsReplica                    : False
IsCloudReplica               : False
IsVmCopy                     : False
IsTapeBackup                 : False
HasNoJobRecord               : False
IsFileTapeBackup             : False
IsVmTapeBackup               : False
IsNasBackup                  : False
IsNasBackupCopy              : False
IsAgentManagementChildJob    : False
IsAgentManagementParentJob   : False
IsAgentPolicyChildJob        : False
IsAgentStandaloneJob         : False
LinkedJobs                   : {}
LinkedJobIds                 : {}
LinkedRepositories           : {}
LinkedRepositoryIds          : {}
LinkedBackups                : {}
IsForeverIncremental         : False
IsBackupJob                  : True
IsEndpointJob                : False
IsLinuxEndpointJob           : False
IsMacEndpointJob             : False
SheduleEnabledTime           : 24/04/2019 17:24:17
IsBackupCopyGfsEnabled       : False
AutoScheduleOptions          : Veeam.Backup.Model.CAutoScheduleOptions
PreviousJobIdInScheduleChain :
LatestRunLocal               : 23/10/2021 08:30:14

For info, here's how the PHP Var_Dump() function works. The third element of the $a array is a nested array, but is still automatically expanded by the function....

Code: Select all

<?php
$a = array(1, 2, array("a", "b", "c"));
var_dump($a);
?>

The above example will output:

array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  array(3) {
    [0]=>
    string(1) "a"
    [1]=>
    string(1) "b"
    [2]=>
    string(1) "c"
  }
}
I'm sure such a tool already exists in the Powershell world somewhere - it's just a case of tracking it down!
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

After a fair bit of Googling, I'm stunned that I can only find a single project that appears to tackle this problem. Unfortunately, it doesn't cater for the extended object types Veeam creates :(

https://github.com/9999years/PSVarDump
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by soncscy »

Sorry but is there a reason Get-Member for the above isn't appropriate? Get-Member has the -Type parameter to filter it out:

Code: Select all

PS /Users/hc> $object = Get-Date                   
PS /Users/hc> $object | Get-Member -Type           
AliasProperty          Dynamic                Method                 Properties             ScriptProperty         
All                    Event                  Methods                Property               
CodeMethod             InferredProperty       NoteProperty           PropertySet            
CodeProperty           MemberSet              ParameterizedProperty  ScriptMethod           
PS /Users/hc> $object | Get-Member -Type Propert
Properties   Property     PropertySet  
PS /Users/hc> $object | Get-Member -Type properties
                   
                  
   TypeName: System.DateTime 
Name        MemberType     Definition
----        ----------     ----------
DisplayHint NoteProperty   DisplayHintType DisplayHint=DateTime
Date        Property       datetime Date {get;}
Day         Property       int Day {get;}
DayOfWeek   Property       System.DayOfWeek DayOfWeek {get;}
DayOfYear   Property       int DayOfYear {get;}
Hour        Property       int Hour {get;}
Kind        Property       System.DateTimeKind Kind {get;}
Millisecond Property       int Millisecond {get;}
Minute      Property       int Minute {get;}
Month       Property       int Month {get;}
Second      Property       int Second {get;}
Ticks       Property       long Ticks {get;}
TimeOfDay   Property       timespan TimeOfDay {get;}
Year        Property       int Year {get;}
DateTime    ScriptProperty System.Object DateTime {get=if ((& { Set-StrictMode -Version 1; $this.DisplayHint }) -ieq  "Date")…

The output of the objects are objects, yes, but Get-Member should do exactly what you need. A custom array like you found or in your example doesn't really work cause Powershell handles it differently as it's actually multiple items added to the array. You can cast it as PSCustomObject and return what you're more thinking I think:

Code: Select all

PS /Users/hc> $CustomArray = [pscustomobject]@{Name=[string]"Hello";Number=[int]"12"}
PS /Users/hc> $cu
cursorColumn               CustomArray                CurrentlyExecutingCommand  
PS /Users/hc> $CustomArray

Name  Number
----  ------
Hello     12

PS /Users/hc> $CustomArray | gm


   TypeName: System.Management.Automation.PSCustomObject
Name        MemberType   Definition
----        ----------   ----------
Equals      Method       bool Equals(System.Object obj)
GetHashCode Method       int GetHashCode()
GetType     Method       type GetType()
ToString    Method       string ToString()
Name        NoteProperty string Name=Hello
Number      NoteProperty int Number=12

PS /Users/hc> $CustomArray.Name
Hello
PS /Users/hc> $CustomArray.Number
12
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

Only in that Get-Member isn't recursive Harvey (AFAIK).

The structure for some of the Veeam objects can be a little hard to work with especially finding that particular setting you're looking for. Searching through a recursive output 'might' help. It's perhaps not an appropriate conversation here as it's a Powershell issue rather than Veeam.

Rob.
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by soncscy »

It can be though, but you need to pass it to Format-Custom afaik and use the -Depth parameter (accepts an int value) and for -Property just define *.

I must admit I never did this with Veeam Objects as it's not how I go about it (it's not really how powershell works tbh), but play with this a bit: https://docs.microsoft.com/en-us/powers ... rshell-7.1
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by ratkinsonuk »

Thanks Harvey, setting the depth to 5 gave around 4000 lines of information, and is just what I wanted.

Code: Select all


$VBRJobObjects | format-custom -depth 5 | out-file "rob.txt"

. . . . . . .

      GenerationPolicy = 
        class CDomGenerationPolicy
        {
          EnableDeletedVmDataRetention = True
          DeletedVmsDataRetentionPeriodDays = 90
          IsBackupCopySimpleMode = False
          RecoveryPointObjectiveValue = 1
          RecoveryPointObjectiveUnit = Day
          SyncIntervalStartTime = 
            class TimeSpan
            {
              Ticks = 270000000000
              Days = 0
              Hours = 7
              Milliseconds = 0
              Minutes = 30
              Seconds = 0
              TotalDays = 0.3125
              TotalHours = 7.5
              TotalMilliseconds = 27000000
              TotalMinutes = 450
              TotalSeconds = 27000
            }
          DeletionGuardDays = 21
          UseDeletionGuardDays = True
          RetentionPolicyType = Simple
          KeepGfsBackup = False
          SimpleRetentionRestorePoints = 7
          EnableCompactFull = False

soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Setting The 'Periodic Copy' Start Time for Copy Jobs

Post by soncscy »

Ahahaha I'm happy you got what you wanted :)

I must admit I rarely use this, but if it works for you, I'm happy to help.

To be clear, I __do__ get your commentaries on Powershell's "uniqueness". It's a very weird language that wants to be bash, C#, and its own thing all at once, and the end result is that it's none of these in the long run. It can be quite useable, and I love the portability it has (I write a script for my Veeam using clients, and I know in general it works on all environments unless I start using .NET methods). But at the same time, the ubiquity comes only with heavy limitations, and you can't treat it like a proper language because of this (without using fairly obscure cmdlets like the above). Similarly, you can't get the same utility you get with bash because PowerShell is just far too slow for such things and too cumbersome in most cases.

It's a language I love to hate, but I must admit I use it far more than I ever thought I would, and I actually take time to write powershell scripts I intend to maintain; I cannot say the same about bash scripts we write for clients.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests