Its probably a simple question. I would like to retrieve a specific AD value for All AD users, and output the results to a <SamAccountName>.txt file. I also want to make sure the output is trimmed. Its probably a For-Each to cycle through all users. So for example, say i wanted to retrieve the “logonCount” for user JSmith. The manual command would be:
In my case, i need each users count to be outputted to a separate file, saved as SamAccountName.txt and contain “just” the logon count value (e.g. 100)
This time i have saved the results from the Get-ADUser cmdlet and used the Select-object cmdlet to filter the returning object so that it only contains two properties;
Logoncount and SamAccountName
I have then just looped through the object and exported the Logoncount property for each object and used the SamAccountName property to name the file.
Awesome! This is perfect. Just one last question. How do i get it to trim (slimier to the -skip 1). For example, if use this method to retrieve PasswordLastSet, then the text file has the first line empty. The results is on the second line.