如何使用 PowerShell 获取系统上的所有用户配置文件?

powershellmicrosoft technologiessoftware & coding

所有新的用户配置文件均在 Windows 系统上的以下路径下创建:

"HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\"

要检索所有用户配置文件,我们可以使用:

gci "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" | ForEach-Object { $_.GetValue("ProfileImagePath") }

ProfileImagePath 属性显示用户配置文件的位置。

另一种检索用户配置文件的方法是使用 WMI。

PS C:\> gwmi win32_userprofile |Select -ExpandProperty LocalPath

输出

C:\Users\.NET v2.0 Classic
C:\Users\.NET v4.5 Classic
C:\Users\.NET v2.0
C:\Users\.NET v4.5
C:\Users\Classic .NET AppPool
C:\Users\Administrator.AUTOMATIONLAB
C:\Users\delta

相关文章