memberof attribute value is not getting stored in excel shee

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 6 years, 5 months ago.

  • Author
  • #5351

    by Nidhin CK at 2012-12-14 11:42:15

    Hi Experts – I'm trying to update the memberof attribute value of one user object to excel sheet. But it is not working could someone help me

    $excelfile = New-Object -ComObject excel.application
    $sheet1 = $excelfile.Worksheets.item(1)
    $excelfile.visible = $true
    $sheet1.cells.item(1,1) = "Member Of"
    $WorkBook = $Sheet1.UsedRange

    Import-Module activedirectory
    $a= Get-ADUser -SearchBase "OU=Test,OU=CHE,OU=IN,DC=asia,DC=com" -Filter * -Properties memberOf
    $sheet1.cells.item($rowno,1) = $a.memberof

    but below command is working fine
    Get-ADUser -Filter {samaccountname -like "nidhin"} -Properties memberof

    by ArtB0514 at 2012-12-14 13:51:30

    The MemberOf property is an array object and can't be added directly to an Excel cell which is looking for a string, number, date, etc. Try this and see if it works:

    $sheet1.Cells.Item($RowNo,1) = $a.MemberOf -Join "`n"

    by Nidhin CK at 2012-12-14 14:19:29

    Thanks a lot Sir.. Your command is working fine.

You must be logged in to reply to this topic.