Powershell how to get Properties values when exporting CSV file

Javier Juarez 21 Reputation points
2023-01-24T21:31:47.05+00:00

Hello. Need some help, I'm trying to get a report with specific details from the Get-AzRecoveryServicesBackupJobDetail command.

So I'm saving the result in an array to later export to a CSV like this:

$JobCompletedDetails = Get-AzRecoveryServicesBackupJobDetail -Job $JobsCompleted[$i] -VaultId $vault.ID

$jobsArray += $JobCompletedDetails

After I complete building the array when I try to export to a CSV, I want to pass the backup size, which is included in the properties (placing myself in position 0 of the array)

PS C:\Users\userName> $jobsArray[0].Properties

Key Value


VM Name Vmname

Backup Size 1127 MB

If I try to export it like this it doesn't get any values.

    $jobsArray | Select-Object WorkloadName, Status, JobId, StartTime, EndTime, Duration, Properties.Values | Export-Csv -NoTypeInformation -Path $file

How can I get the value of the size only like this to get passed as a column in my CSV?:

PS C:\Users\UserName> $jobsArray[0].Properties.Values

Vmname

1127 MB (This is the only value I want)

Thanks for the help.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
6,845 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
1,867 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Rich Matheisen 44,081 Reputation points
    2023-01-25T16:40:49.87+00:00

    If you only want to add the value of the "Backup Size" property to your CSV then this might be all you need:

    $jobsArray | 
        Select-Object WorkloadName, Status, JobId, StartTime, EndTime, Duration, "Backup Size" | 
            Export-Csv -NoTypeInformation -Path $file
    
    0 comments No comments