I am using this question as my base reference Powershell - Query remote registry key value and generate text file IF value equals 1
I am trying to find the value of a registry key and output that to a file.
I modifed the code in that link to look like this.
$keyname = 'Software\Policies\Microsoft\Windows\WindowsUpdate\AU'
Import-Csv 'C:\computers.csv' | % {
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",
$_.machinename)
$key = $reg.OpenSubkey($keyname)
$value = $key.GetValue('AUoptions')
Write-Host ($_.machinename , $value) | write-output "c:\computerresults.csv"
The script works correctly until I get to the | write-output. I cannot get it to dump the results to a file. I tried export-csv as well.
Any assistance given would be greatly appericated.