locked
Embedded nulls in Powershell created file

    Question

  • I am having a rather interesting problem, hopefully someone can help me out.

    I am using Powershell to create an CSV file the MIIS/ILM uses for import. The file itself is a list of windows Ids and displaynames that are the group memberships of three separate AD groups.

    When I try and import the CSV into MIIS, I get an "stopped-file-embedded-nulls" error an no records are imported. Interestingly if I copy the entire file contents to a new file, that file imports into MIIS without any errors.

    I have no idea where these nulls are coming from, but certainly don't see anything odd when I use a text editor like Textpad and show all characters.

    Any ideas or has anyone seen Powershell create files that have odd or hidden nulls in them?

    Thursday, April 15, 2010 2:49 PM

All replies

  • Yes, PowerShell does add some extra hidden characters into files.  I'm not sure if all the cmdlets do though.

    Can you provide more details on how you need to create the file?  Maybe if you use something from the .NET framework, then you'll be all set.

    Friday, April 16, 2010 2:27 PM
    Moderator
  • I am using one of the Quest commandlets:

    get-QADGroupMember $group -sizelimit 0 | select-object samAccountName, displayName | export-csv $Outfile

    Thanks Marco!

     

    Friday, April 16, 2010 2:34 PM
  • I also tried the following (so I could remove the null), and no luck either?

    $Users = get-QADGroupMember $group -sizelimit 0 | select-object samAccountName, displayName
     foreach($User in $Users){
      $Sam = $User.samAccountName.Trim() -replace($null,"")
      $DisplayName = $User.displayName.Trim() -replace($null,"")
      $Sam + ",""" + $DisplayName + """" | out-file $Output -append
     }

     

    Anyone have an ideas how to get rid of them?

    Friday, April 23, 2010 3:59 PM