I am new to PowerShell so apologies if I don’t explain this clearly. I have a file that contains a list of directories/folders in a CSV. I want to loop over each of those file paths and return the users who have access to that file directory/folders. So far I have the following script:
It is returning a list of users which is great however I need to script to return the variable $folder for each row so I know which folder in this list the user has access to.
Current Output
IdentityReference
User1
User2
User3
User4
User5
Desired Output
IdentityReference
Folder
User1
Folder1
User2
Folder1
User3
Folder2
User4
Folder2
User5
Folder3
I need the 2nd column to output the folder that the script that looped over as well.
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Could I ask one more question. The script works fine and returns the information I need however when I export the data to a csv it is truncating the string in each row and is returning … I had a quick google, apparently -AutoSize is supposed to return all the data in the output but the rows are still be truncated, any solutions?
You’re not exporting CSV, you are creating custom string output. Remove the format table and out file commands and instead use select-object to grab the desired properties and pipe that to export-csv