リモート サーバー (読み取り専用) でファイルをホストし、インストールされているプログラムの情報を収集するために、自分のマシンでファイルを実行するよう人々に依頼します。ファイルをデスクトップのユーザー スペースに保存して、送信してもらいたいのです。
スクリプトはありますが、同じ出力ファイルで「 SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall」と「Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall 」の両方から情報を取得できません。PowerShell は明らかにこれを行うことができるため、明らかに本質的に明らかな何かが欠けています。PEBKAC の問題から誰かが私を救ってくれるようお願いしています!
よろしくお願いします!
これが私のコードです。
$computers = "$env:computername"
$array = @()
foreach($pc in $computers){
$computername=$pc
$UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$UninstallKey="Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computername)
$regkey=$reg.OpenSubKey($UninstallKey)
$subkeys=$regkey.GetSubKeyNames()
Write-Host "$computername"
foreach($key in $subkeys){
$thisKey=$UninstallKey+"\\"+$key
$thisSubKey=$reg.OpenSubKey($thisKey)
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $computername
$obj | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $($thisSubKey.GetValue("DisplayName"))
$obj | Add-Member -MemberType NoteProperty -Name "DisplayVersion" -Value $($thisSubKey.GetValue("DisplayVersion"))
$obj | Add-Member -MemberType NoteProperty -Name "InstallLocation" -Value $($thisSubKey.GetValue("InstallLocation"))
$obj | Add-Member -MemberType NoteProperty -Name "Publisher" -Value $($thisSubKey.GetValue("Publisher"))
$array += $obj
}
}
$array | Where-Object { $_.DisplayName } | select ComputerName, DisplayName, DisplayVersion, Publisher | export-csv C:\Users\$env:username\Desktop\Installed_Apps.csv