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

所有新的用户配置文件都是在 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