Use PowerShell to get user home directory, Home Drive, Last Logon and account status

Use PowerShell to get user home directory, Home Drive, Last Logon and account status

You can user PowerShell to get the user Home Drive, Home Directory, last logon date and account status. This can help with user account cleanup and home drive / home folder cleanup. This script needs to be run with Active Directory PowerShell module. For more info on how to add and execute the module please see https://learn.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps

Get-ADUser -Filter 'PasswordNotRequired -eq $false' -Properties ProfilePath, HomeDirectory, HomeDrive, LastLogonDate, UserPrincipalName, Enabled | Select Name, LastLogonDate, SamAccountName, ProfilePath, HomeDirectory, HomeDrive, UserPrincipalName, Enabled | Export-Csv -path "c:\temp\userlistProf_logondate3.csv"        

After export runs, open the file with Excel and save as XLSX

Now you can add a filter and use it to view the information you need, for example home drives of enabled account only, or account that have not been logged on to for a certain period of time.

PowerShell get user home drive


要查看或添加评论,请登录

社区洞察

其他会员也浏览了