locked
Changing multiple Headers in CSV (Information Dissapears) RRS feed

  • Question

  • Hello,

    $Select = @{
    'Filter' = '*'
    'searchbase'='OU=TESTOU,DC=corp,DC=Sample,DC=com'
    'Properties'= @("GivenName","SurName","DisplayName","samaccountname","Streetaddress","state","City","PostalCode","Country","Title","Company","Department","Office","telePhonenumber")
    }
    
    $propertyTranslation = @(
        @{ Name = 'User Name'; Expression = 'UserPrincipalName' }
        @{ Name = 'First Name';   Expression = 'GivenName'}
        @{ Name = 'Last Name';   Expression = 'SurName'}
        @{ Name = 'Display Name';   Expression = 'DisplayName' }
        @{ Name = 'Job Title';   Expression = 'Title' }
        @{ Name = 'Department';   Expression = 'Department' }
        @{ Name = 'Office Phone';   Expression = 'telePhonenumber' }
        @{ Name = 'Address';   Expression = 'StreetAddress' }
        @{ Name = 'City';   Expression = 'City'  }
        @{ Name = 'Zip or Postal Code';   Expression = 'PostalCode' }
        @{ Name = 'Country or Region';   Expression = 'Country' }
    )
    
    Get-ADUser @select
    Select-Object -Property $propertyTranslation
    export-csv c:\Test0901.csv -notype -delimiter ","
    
    (Import-Csv -Path 'c:\Test0901.csv') |
    Select-Object -Property $propertyTranslation |
    Export-Csv c:\Test0230.csv -NoTypeInformation -delimiter ","

    This works for Changing the Headers but I dont get any Information About the user in the OU.



    Thursday, February 15, 2018 8:44 AM

All replies

  • An expression refers to the pipeline object:

    @{ n = 'User Name'; e ={$-.UserPrincipalName}}

    Search for articles on computed properties.


    \_(ツ)_/

    Thursday, February 15, 2018 9:06 AM