Simple problem with import-csv

Welcome Forums General PowerShell Q&A Simple problem with import-csv

This topic contains 2 replies, has 2 voices, and was last updated by

2 years, 5 months ago.

  • Author
  • #48599

    Points: 0
    Rank: Member

    I have a simple CSV:


    I want to assign rights to a folder with that same name, which I have done in the past using this cmdlet, using:

      $users5 = import-csv C:\Users\swindmiller\Desktop\Users5.csv
      ForEach ($Folder in $users5) {
      Add-NTFSAccess -path \\FileSERVER\Users\$Folder.Name -Account MYDOMAIN\$folder.Name -AccessRights FullControl


    This is my error:

      Add-NTFSAccess : Cannot bind parameter 'Account'. Cannot convert value "MYDOMAIN\@{Name=Aashley}.Name" to type "Security2.IdentityReference2". Error:
      "Some or all identity references could not be translated."
      At line:3 char:90
      + ... fileSERVER\Users\$Folder.Name -Account MYDOMAIN\$folder.Name -Access ...
      + ~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidArgument: (:) [Add-NTFSAccess], ParameterBindingException
      + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,NTFSSecurity.AddAccess

    I know the problem is in "@{Name=Aashley}.Name", it's not letting me reference just the name and I cannot for the life of me figure out why. Shouldn't $Folder.Name just give me "Aashley"?

    I KNOW this is going to be a stupid problem on my part so be easy 🙂

  • #48603

    Points: 0
    Rank: Member
    Add-NTFSAccess -path "\\FileSERVER\Users\$($Folder.Name)" -Account "MYDOMAIN\$($folder.Name)" -AccessRights FullControl

    Have to wrap the variable with a property in a subexpression $(). Otherwise it attempts to turn the variable into a string before it gets to the .name.

    • #48610

      Points: 0
      Rank: Member

      Thanks! I knew it was something simple but something I would need to know for the worked perfectly.

      Thanks for your fast help!

The topic ‘Simple problem with import-csv’ is closed to new replies.