-
- Veeam Software
- Posts: 154
- Liked: 42 times
- Joined: Jan 17, 2012 5:47 pm
- Full Name: Tomasz Krajewski
- Contact:
Call for Powershell script
Guys! As I am total PS noob, I call for help. We have project that we are required to integrate with storage vendor (HDS) reporting tool. ONE is out of question in this project unfortunately and HDS reporting tool has no plugin for our software. It can accept CSV file in certain format that has simple description of job states. I know that with PS we can output to CSV but need to give partner some simple example, and that's why I call for help. This is snippet from documentation:
Using the backup software, create a comma-separated file that contains the following data elements from the
backup/restore job(s). Note that each field must have an entry, even if it is a null entry within the commas. Field values cannot contain embedded commas. All string fields must be enclosed within single straight quotes.

Name Type Value
VendorName STRING The name of the backup application used to perform the backup, enclosed in single straight quotes
ClientName STRING The host name of the machine being backed up, enclosed in single straight quotes
ClientIPAddress NUMBER The IP address of the machine being backed up (otherwise use 'null'), enclosed in single straight quotes
VendorJobType STRING Valid values include: BACKUP or RESTORE—enclosed in single straight quotes
StartDateString DATE The start date and time of the backup job in the format: YYYY-MM-DD HH:MI:SS (enclosed in single straight quotes)
FinishDateString DATE The end date and time of the backup job in the format: YYYY-MM-DD HH:MI:SS (enclosed in single straight quotes)
BackupKilobytes NUMBER The numeric size of the backup in kilobytes (otherwise use 0). Remember StorageConsole uses 1024 for a KB.
NbrOfFiles NUMBER The number of files that were backed up (otherwise use 0).
MediaType STRING The type of media that was used: T for Tape or D for Disk, enclosed within single straight quotes.
VendorStatus NUMBER A numeric job status: 0=Successful, 1=Partially Successful, or 2=Failed.
VendorJobId NUMBER Vendor job ID.
VendorPolicyName STRING Vendor policy name.
JobLevel STRING Ex: Incremental, full.
TargetName STRING File system backed up by MBS.
Example output that is accepted by the system:
'Mainframe Backup','mainframe_name','10.10.10.10','BACKUP','2008-03-24 10:25:00', '2008- 03-24 11:50:00',3713,45221,'D',0,413824,'Retail_s01002030','Incremental','/I:/Shared/'
Does any of the PS gurus can help? I can certainly try to dig into this myself but time is a bit of issue here with this project
Thanks!
Using the backup software, create a comma-separated file that contains the following data elements from the
backup/restore job(s). Note that each field must have an entry, even if it is a null entry within the commas. Field values cannot contain embedded commas. All string fields must be enclosed within single straight quotes.

Name Type Value
VendorName STRING The name of the backup application used to perform the backup, enclosed in single straight quotes
ClientName STRING The host name of the machine being backed up, enclosed in single straight quotes
ClientIPAddress NUMBER The IP address of the machine being backed up (otherwise use 'null'), enclosed in single straight quotes
VendorJobType STRING Valid values include: BACKUP or RESTORE—enclosed in single straight quotes
StartDateString DATE The start date and time of the backup job in the format: YYYY-MM-DD HH:MI:SS (enclosed in single straight quotes)
FinishDateString DATE The end date and time of the backup job in the format: YYYY-MM-DD HH:MI:SS (enclosed in single straight quotes)
BackupKilobytes NUMBER The numeric size of the backup in kilobytes (otherwise use 0). Remember StorageConsole uses 1024 for a KB.
NbrOfFiles NUMBER The number of files that were backed up (otherwise use 0).
MediaType STRING The type of media that was used: T for Tape or D for Disk, enclosed within single straight quotes.
VendorStatus NUMBER A numeric job status: 0=Successful, 1=Partially Successful, or 2=Failed.
VendorJobId NUMBER Vendor job ID.
VendorPolicyName STRING Vendor policy name.
JobLevel STRING Ex: Incremental, full.
TargetName STRING File system backed up by MBS.
Example output that is accepted by the system:
'Mainframe Backup','mainframe_name','10.10.10.10','BACKUP','2008-03-24 10:25:00', '2008- 03-24 11:50:00',3713,45221,'D',0,413824,'Retail_s01002030','Incremental','/I:/Shared/'
Does any of the PS gurus can help? I can certainly try to dig into this myself but time is a bit of issue here with this project
Thanks!
Tomasz
-
- Product Manager
- Posts: 20411
- Liked: 2299 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Call for Powershell script
Hi, Tomasz,
Most of this information is, indeed, available via PS:
Thanks.
Most of this information is, indeed, available via PS:
Code: Select all
$Job = Get-VbRjob -name "Name of your backup job"
$Job.Name #Name
$Job.id.guid #ID
$Job.ScheduleOptions.LatestRun #Latest run
$Job.ScheduleOptions.NextRun #Next run
$Job.info.targetdir #Target directory
Code: Select all
$Backup = Get-VBRBackup -NAME $Job.name
$BackupSize = $Null
Foreach ($Storage in $Backup.GetStorages())
{
$BackupSize = $BackupSize + $Storage.Stats.BackupSize
}
$BackupSize/1mb #Backup Size
-
- Veeam Software
- Posts: 154
- Liked: 42 times
- Joined: Jan 17, 2012 5:47 pm
- Full Name: Tomasz Krajewski
- Contact:
Re: Call for Powershell script
Thanks! That's a good start, from my research the most troublesome part would be formatting CSV in proper way, especially converting date format, I think in PS value returned depends on regional Windows settings. But I see that we have all information needed to feed this CSV.
Thanks!
Thanks!
Tomasz
-
- Product Manager
- Posts: 20411
- Liked: 2299 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Call for Powershell script
You can use the following trick in order to convert the datetime to the desired format:
Thanks.
Code: Select all
$Job.ScheduleOptions.LatestRun.ToString('yyyy-MM-dd HH:mm:ss')
-
- Veeam Software
- Posts: 1818
- Liked: 655 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: Call for Powershell script
You could make an array with custom objects then feed it to convertto-csv. You can use select-object to define the order of the objects
Code: Select all
Add-PSSnapin VeeamPSSnapIn
$lines = @()
get-vbrjob | ? { $_.JobType -eq "Backup" } | % {
$jobname = $_.name
$Backups = Get-VBRBackup -name $jobname
[long]$BackupSize = 0
Foreach ($Backup in $Backups) {
Foreach ($Storage in $Backup.GetStorages())
{
$BackupSize = $BackupSize + $Storage.Stats.BackupSize
}
}
[long]$BackupSize /= (1024*1024)
$lines += New-Object -TypeName PSObject -Property @{ Job=$jobname;BackupSize=$BackupSize }
}
$lines | select-object Job,BackupSize | ConvertTo-Csv -Delimiter "," -NoTypeInformation
Who is online
Users browsing this forum: No registered users and 21 guests