Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Help Exporting to CSV

$
0
0

Hi,

I need to export publicdelegates to CSV file, unfortunately though I need it to export the ntaccountname.

$a= get-qaduser -SizeLimit 0 -searchroot "OU" -SearchScope Subtree -ldapfilter '(mail=*)' -IncludedProperties displayname, publicdelegates, publicdelegatesbl
    foreach ($user in $a) {
         $user.displayname
         "================================="
         if ($user.publicdelegates -eq $null) {
                 Write-host "Has no delegates"
         } else
         {      
                Write-host "PublicDelegate:"
             $b = $user.publicdelegates;
                 foreach ($del in $b) {Get-QADUser $del | select-object ntaccountname | sort-object ntaccountname };
               
         }
        
        if ($user.publicdelegatesbl -eq $null) {
                 Write-host "Is not a delegate"
         } else
         {
                         Write-Host 'PublicDelagetBL:'
                     $b = $user.publicdelegatesbl;
                         foreach ($del in $b) {Get-QADUser $del |select-object ntaccountname | sort-object ntaccountname };
          }
         }

However, I really am having trouble exporting this nicely to CSV

I am aiming for

Name, PublicDelegate, PublicDelegateBL
user1, domain\user2, domain\user3

The above script does this but, it won't export it into a csv file


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>