Thanks much for the reply.
Please let me know what I am missing. Thanks again.
Copied a backup script that used this command in the script that starting failing after upgraded to veeam 8:
Code: Select all
$Credentials = New-Object -TypeName Veeam.Backup.Common.CCredentials -ArgumentList $cred1,$cred2,0,0
New-Object cmdlet creates instance of type Veeam.Backup.Common.CCredentials.
veeam.backup.common.ccredentials is a static type.
Just put [] around it and you can use it.
Code: Select all
PS C:> [Veeam.Backup.Common.CCredentials] | get-member -static
TypeName: Veeam.Backup.Common.CCredentials
Name MemberType Definition
---- ---------- ----------
AddToXml Method static void AddToXml(System.Xml.XmlNode parentNode, Veeam.Backup.Common.CCredential...
Clone Method static Veeam.Backup.Common.CCredentials Clone(Veeam.Backup.Common.CCredentials creds)
Create Method static Veeam.Backup.Common.CCredentials Create(string userName, string password)
CreateEmpty Method static Veeam.Backup.Common.CCredentials CreateEmpty(bool isLocalProtect)
Deserialize Method static Veeam.Backup.Common.CCredentials Deserialize(string credsXml)
Equals Method static bool Equals(System.Object objA, System.Object objB)
FromXmlData Method static Veeam.Backup.Common.CCredentials FromXmlData(Veeam.Backup.Common.COutputXmlD...
GetFromXml Method static Veeam.Backup.Common.CCredentials GetFromXml(System.Xml.XmlNode parentNode)
IsEqual Method static bool IsEqual(Veeam.Backup.Common.CCredentials credentials1, Veeam.Backup.Com...
IsNullOrEmpty Method static bool IsNullOrEmpty(Veeam.Backup.Common.CCredentials credentials)
ReferenceEquals Method static bool ReferenceEquals(System.Object objA, System.Object objB)
Unserial Method static Veeam.Backup.Common.CCredentials Unserial(System.Xml.XmlNode node)
LINUX_USERNAME_RESTRICTED_SYMBOLS Property static string LINUX_USERNAME_RESTRICTED_SYMBOLS {get;}
RootTag Property static string RootTag {get;}
WINDOWS_USERNAME_RESTRICTED_SYMBOLS Property static string WINDOWS_USERNAME_RESTRICTED_SYMBOLS {get;}
OK so PTide was kind enough to tell me to look in reference guide.
Find cmdlet Get-VBRCredentials. Let’s try that.
Code: Select all
PS C:\users\veeam\scripts\addbk> Get-VBRCredentials | Get-Member -static
TypeName: Veeam.Backup.Common.CCredentials
Name MemberType Definition
---- ---------- ----------
AddToXml Method static void AddToXml(System.Xml.XmlNode parentNode, Veeam.Backup.Common.CCredential...
Clone Method static Veeam.Backup.Common.CCredentials Clone(Veeam.Backup.Common.CCredentials creds)
Create Method static Veeam.Backup.Common.CCredentials Create(string userName, string password)
CreateEmpty Method static Veeam.Backup.Common.CCredentials CreateEmpty(bool isLocalProtect)
Deserialize Method static Veeam.Backup.Common.CCredentials Deserialize(string credsXml)
Equals Method static bool Equals(System.Object objA, System.Object objB)
FromXmlData Method static Veeam.Backup.Common.CCredentials FromXmlData(Veeam.Backup.Common.COutputXmlD...
GetFromXml Method static Veeam.Backup.Common.CCredentials GetFromXml(System.Xml.XmlNode parentNode)
IsEqual Method static bool IsEqual(Veeam.Backup.Common.CCredentials credentials1, Veeam.Backup.Com...
IsNullOrEmpty Method static bool IsNullOrEmpty(Veeam.Backup.Common.CCredentials credentials)
ReferenceEquals Method static bool ReferenceEquals(System.Object objA, System.Object objB)
Unserial Method static Veeam.Backup.Common.CCredentials Unserial(System.Xml.XmlNode node)
LINUX_USERNAME_RESTRICTED_SYMBOLS Property static string LINUX_USERNAME_RESTRICTED_SYMBOLS {get;}
RootTag Property static string RootTag {get;}
WINDOWS_USERNAME_RESTRICTED_SYMBOLS Property static string WINDOWS_USERNAME_RESTRICTED_SYMBOLS {get;}
Wow, same TypeName!
Add-VBRCredentials looks like it has all parameters needed. I will try that.
But if I wanted to use the static type and give it an argument list, is there a way to figure out the argument list.
Turns out there is. From:
http://learn-powershell.net/2013/03/14/ ... owershell/
Code: Select all
PS C:\users\veeam\scripts\addbk> ([type]"veeam.backup.common.ccredentials").GetConstructors() | ForEach {
$_.GetParameters()
} | Select Name,ParameterType
Name ParameterType
---- -------------
userName System.String
password System.String
userName System.String
password System.String
currentUser System.Boolean
isLocalProtect System.Boolean
changeTimeUtc System.Nullable`1[System.DateTime]
userName System.String
password System.String
currentUser System.Boolean
isLocalProtect System.Boolean
description System.String
changeTimeUtc System.Nullable`1[System.DateTime]
And this script is even better:
Code: Select all
PS C:\users\veeam\scripts\addbk> ([type]"veeam.backup.common.ccredentials").GetConstructors() | ForEach {
($_.GetParameters() | ForEach {$_.ToString()}) -Join ", "
}
System.String userName, System.String password
System.String userName, System.String password, Boolean currentUser, Boolean isLocalProtect, System.Nullable`1[System.DateTime] chang
eTimeUtc
System.String userName, System.String password, Boolean currentUser, Boolean isLocalProtect, System.String description, System.Nullab
le`1[System.DateTime] changeTimeUtc