MyITGuy
3/1/2018 - 3:23 PM

PowerShell: Export Get-QARSOperation

This is an example of how to export objects from Get-QARSOperation.

$QARSOperations = Get-QARSOperation -CompletedRecently ([timespan]::FromDays(1)) -Proxy
$QARSOperations | Select @{Name="AttributeChanges";Expression={$_.AttributeChanges.Name -join ','}},@{Name="Controls";Expression={$_.Controls.ID -join ','}},ID,OperationGuid,Type,Status,Initiated,Completed,@{Name="InitiatedBy";Expression={$_.InitiatorInfo.NTAccountName}},@{Name="Target";Expression={$_.TargetObjectInfo.DN}} | Export-Csv -NoTypeInformation -Path .\QARSOperation_Last_Day.csv
Get-QARSOperation -CompletedOn 'Today' -Proxy -TargetObjectType 'group' -OperationType 'Modify' | Sort-Object -Property Completed | ForEach-Object {
    $Properties = [ordered]@{
        Completed   = $_.Completed
        Type        = $_.Type
        ObjectClass = $_.TargetObjectInfo.ObjectClass
        ObjectGuid  = $_.TargetObjectInfo.Guid
        ObjectName  = $null
        DN          = $_.TargetObjectInfo.DN
        InitiatedBy = $_.InitiatorInfo.NTAccountName
    }
    try {
        $Properties.ObjectName = Get-QADObject -Identity $_.TargetObjectInfo.Guid -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name
    }
    catch {}
    $obj = New-Object -TypeName PSObject -Property $Properties
    Write-Output -InputObject $obj
}