Need help with an PowerShell command to extract user attributes
Posted on 2016-07-21
Hello, what I need to do is get a CSV file with two columns - the first with a list of all users in AD, and the other column with the value of the AD attribute 'userSharedFolder' for that user.
I'm a PowerShell learner. Here's what I have so far...
Get-ADUser –Filter * -prop cn,userSharedFolder | select cn,userSharedFolder > \\server\share\IT\Scripts\AD\Ldrive.csv
Now, all the info is there in the resulting CSV, but there are a few formatting issues. Firstly, the output is not on separate columns in Excel - it's all on the same column, just with loads of white space between the username and the userSharedFolder. How do I get them onto separate columns, with no white space? Secondly, I have some usernames that have a leading zero, but Excel sees it fit to remove this digit. Can you stop this from happening at the script level, or would this be an Excel thing?
Any other tips to improve the above command would be welcomed.