Powershell get unique entry of first column of an arrayHow do I get the current username in Windows PowerShell?Powershell: Deduping an arrayTrying to export an array to csv using powershell (array objects are ; delimited and contain newlines)Powershell Array questionGetting names of folders that do not inherit permissionsPowerShell get-acl List folder contents vs ReadAndExecutecalling a variable in select -expandpropertyPowerShell Get the first date from event viewer for all entriesPowershell Dynamic Menu Based on Mailbox Permission EntriesI can't get Powershell StartsWith function to work

What is the difference between nullifying your vote and not going to vote at all?

Is this light switch installation safe and legal?

Can't connect to Internet in bash using Mac OS

Beginner's snake game using PyGame

Is having a hidden directory under /etc safe?

What does the behaviour of water on the skin of an aircraft in flight tell us?

What caused the tendency for conservatives to not support climate change regulations?

Is it possible to change original filename of an exe?

The qvolume of an integer

Possible nonclassical ion from a bicyclic system

How to prevent bad sectors?

60s (or earlier) short story where each colony has one person who doesn't connect well with others who is there for being able to absorb knowledge

Infinitely many hats

Can't the Time Stone be touched with bare hands?

Can non-English-speaking characters use wordplay specific to English?

Why to use water tanks from Space shuttle in museum?

Decrypting WPA2-Enterprise (EAP-PEAP) in Wireshark

Is there an explanation for Austria's Freedom Party virtually retaining its vote share despite recent scandal?

How can I prevent interns from being expendable?

How to detach yourself from a character you're going to kill?

Draw a checker pattern with a black X in the center

SPI on stm32 won't work without pullup resistors and even then performs poorly

Thousands and thousands of words

Term for checking piece whose opponent daren't capture it



Powershell get unique entry of first column of an array


How do I get the current username in Windows PowerShell?Powershell: Deduping an arrayTrying to export an array to csv using powershell (array objects are ; delimited and contain newlines)Powershell Array questionGetting names of folders that do not inherit permissionsPowerShell get-acl List folder contents vs ReadAndExecutecalling a variable in select -expandpropertyPowerShell Get the first date from event viewer for all entriesPowershell Dynamic Menu Based on Mailbox Permission EntriesI can't get Powershell StartsWith function to work






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to get unique entries from reading out Filepermissions.



I got the following code snippet. It gives me a list with 2 arrays, one Identityreference and one FileSystemRights.



$ACLFile = Get-Acl -Path $dir -Filter Access | Select-Object -ExpandProperty Access | Where-Object $_.IdentityReference -like "EBK*" | Select-Object IdentityReference, FileSystemRights
$ACLFile = $ACLFile.IdentityReference | select -unique


Now what I did here only gives me IdentityReference as a result but i need both. If I remove the $ACLFile.IdentityReference and just write $ACLLFile it removes duplicates from the FileSystemRights columns but I want only the other column as indicator.










share|improve this question






























    0















    I'm trying to get unique entries from reading out Filepermissions.



    I got the following code snippet. It gives me a list with 2 arrays, one Identityreference and one FileSystemRights.



    $ACLFile = Get-Acl -Path $dir -Filter Access | Select-Object -ExpandProperty Access | Where-Object $_.IdentityReference -like "EBK*" | Select-Object IdentityReference, FileSystemRights
    $ACLFile = $ACLFile.IdentityReference | select -unique


    Now what I did here only gives me IdentityReference as a result but i need both. If I remove the $ACLFile.IdentityReference and just write $ACLLFile it removes duplicates from the FileSystemRights columns but I want only the other column as indicator.










    share|improve this question


























      0












      0








      0








      I'm trying to get unique entries from reading out Filepermissions.



      I got the following code snippet. It gives me a list with 2 arrays, one Identityreference and one FileSystemRights.



      $ACLFile = Get-Acl -Path $dir -Filter Access | Select-Object -ExpandProperty Access | Where-Object $_.IdentityReference -like "EBK*" | Select-Object IdentityReference, FileSystemRights
      $ACLFile = $ACLFile.IdentityReference | select -unique


      Now what I did here only gives me IdentityReference as a result but i need both. If I remove the $ACLFile.IdentityReference and just write $ACLLFile it removes duplicates from the FileSystemRights columns but I want only the other column as indicator.










      share|improve this question
















      I'm trying to get unique entries from reading out Filepermissions.



      I got the following code snippet. It gives me a list with 2 arrays, one Identityreference and one FileSystemRights.



      $ACLFile = Get-Acl -Path $dir -Filter Access | Select-Object -ExpandProperty Access | Where-Object $_.IdentityReference -like "EBK*" | Select-Object IdentityReference, FileSystemRights
      $ACLFile = $ACLFile.IdentityReference | select -unique


      Now what I did here only gives me IdentityReference as a result but i need both. If I remove the $ACLFile.IdentityReference and just write $ACLLFile it removes duplicates from the FileSystemRights columns but I want only the other column as indicator.







      powershell scripting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 9:57









      marc_s

      591k13311301278




      591k13311301278










      asked Mar 7 at 15:34









      seyo -IVseyo -IV

      306




      306






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You could just use Sort-Object here:



          $ACLFile | Sort-Object IdentityReference -unique


          However, there are issues with this approach alone. You will lose your additional FileSystemRights property value for the duplicate IdentityReference. Are you wanting to combine all FileSystemRights belonging to the same IdentityReference into one line?



          The following will remove duplicate IdentityReferences and combine FileSystemRights:



          $ACLGroup = $ACLFile | Group-Object IdentityReference
          $Singles = $ACLGroup.where($_.count -eq 1).group
          $Duplicates = $ACLGroup.where($_.count -gt 1)
          $ItemizedDuplicates = $Duplicates | foreach
          [pscustomobject][ordered]@"IdentityReference"=$_.Group.IdentityReference[0]; "FileSystemRights" = $_.Group.FileSystemRights -join ", "

          @($ItemizedDuplicates,$Singles)





          share|improve this answer

























          • Nice exactly what i needed.

            – seyo -IV
            Mar 8 at 10:09











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047507%2fpowershell-get-unique-entry-of-first-column-of-an-array%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You could just use Sort-Object here:



          $ACLFile | Sort-Object IdentityReference -unique


          However, there are issues with this approach alone. You will lose your additional FileSystemRights property value for the duplicate IdentityReference. Are you wanting to combine all FileSystemRights belonging to the same IdentityReference into one line?



          The following will remove duplicate IdentityReferences and combine FileSystemRights:



          $ACLGroup = $ACLFile | Group-Object IdentityReference
          $Singles = $ACLGroup.where($_.count -eq 1).group
          $Duplicates = $ACLGroup.where($_.count -gt 1)
          $ItemizedDuplicates = $Duplicates | foreach
          [pscustomobject][ordered]@"IdentityReference"=$_.Group.IdentityReference[0]; "FileSystemRights" = $_.Group.FileSystemRights -join ", "

          @($ItemizedDuplicates,$Singles)





          share|improve this answer

























          • Nice exactly what i needed.

            – seyo -IV
            Mar 8 at 10:09















          1














          You could just use Sort-Object here:



          $ACLFile | Sort-Object IdentityReference -unique


          However, there are issues with this approach alone. You will lose your additional FileSystemRights property value for the duplicate IdentityReference. Are you wanting to combine all FileSystemRights belonging to the same IdentityReference into one line?



          The following will remove duplicate IdentityReferences and combine FileSystemRights:



          $ACLGroup = $ACLFile | Group-Object IdentityReference
          $Singles = $ACLGroup.where($_.count -eq 1).group
          $Duplicates = $ACLGroup.where($_.count -gt 1)
          $ItemizedDuplicates = $Duplicates | foreach
          [pscustomobject][ordered]@"IdentityReference"=$_.Group.IdentityReference[0]; "FileSystemRights" = $_.Group.FileSystemRights -join ", "

          @($ItemizedDuplicates,$Singles)





          share|improve this answer

























          • Nice exactly what i needed.

            – seyo -IV
            Mar 8 at 10:09













          1












          1








          1







          You could just use Sort-Object here:



          $ACLFile | Sort-Object IdentityReference -unique


          However, there are issues with this approach alone. You will lose your additional FileSystemRights property value for the duplicate IdentityReference. Are you wanting to combine all FileSystemRights belonging to the same IdentityReference into one line?



          The following will remove duplicate IdentityReferences and combine FileSystemRights:



          $ACLGroup = $ACLFile | Group-Object IdentityReference
          $Singles = $ACLGroup.where($_.count -eq 1).group
          $Duplicates = $ACLGroup.where($_.count -gt 1)
          $ItemizedDuplicates = $Duplicates | foreach
          [pscustomobject][ordered]@"IdentityReference"=$_.Group.IdentityReference[0]; "FileSystemRights" = $_.Group.FileSystemRights -join ", "

          @($ItemizedDuplicates,$Singles)





          share|improve this answer















          You could just use Sort-Object here:



          $ACLFile | Sort-Object IdentityReference -unique


          However, there are issues with this approach alone. You will lose your additional FileSystemRights property value for the duplicate IdentityReference. Are you wanting to combine all FileSystemRights belonging to the same IdentityReference into one line?



          The following will remove duplicate IdentityReferences and combine FileSystemRights:



          $ACLGroup = $ACLFile | Group-Object IdentityReference
          $Singles = $ACLGroup.where($_.count -eq 1).group
          $Duplicates = $ACLGroup.where($_.count -gt 1)
          $ItemizedDuplicates = $Duplicates | foreach
          [pscustomobject][ordered]@"IdentityReference"=$_.Group.IdentityReference[0]; "FileSystemRights" = $_.Group.FileSystemRights -join ", "

          @($ItemizedDuplicates,$Singles)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 7 at 18:07

























          answered Mar 7 at 16:34









          AdminOfThingsAdminOfThings

          3,3202214




          3,3202214












          • Nice exactly what i needed.

            – seyo -IV
            Mar 8 at 10:09

















          • Nice exactly what i needed.

            – seyo -IV
            Mar 8 at 10:09
















          Nice exactly what i needed.

          – seyo -IV
          Mar 8 at 10:09





          Nice exactly what i needed.

          – seyo -IV
          Mar 8 at 10:09



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047507%2fpowershell-get-unique-entry-of-first-column-of-an-array%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

          밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

          1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴