powershell : 获取PC 端注册表信息


点击查看代码
#定义一个变量用于获取用户注册表信息
$regPath="HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
$regInfo = Get-Item -Path $regPath
#注册表信息

$Info = 1 | Select-Object -Property UserName,ComputerName,regPath,regName, Type, Value
$regInfo.GetValueNames() |
  ForEach-Object {
    $Info.UserName = $env:UserName
    $Info.ComputerName=$env:COMPUTERNAME
    $Info.regName = $_
    $Info.regPath=$regPath
    $Info.Type = $regInfo.GetValueKind($_)
    $Info.Value = $regInfo.GetValue($_)
    $str=$Info.UserName+","+ $Info.ComputerName+","+$Info.regPath+","+$Info.regName+","+$Info.Type+","+$Info.Value
    Add-Content  $str   -Path   \\172.16.XXX.XXX\CITSoft\regInfo.csv
  }