Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Computer Field Missing

$
0
0

The results file doesnt put the computer name from the list. How do I define it in my script?

 

$strMachineName = import-csv C:\temp\PCS.csv

$results=foreach ($line in $strMachineName) {

     try {

         $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Line.Computer)

         $regkey=$reg.OpenSubkey('SOFTWARE\Microsoft\Windows\CurrentVersion\OemInformation')

          New-Object PsObject -Property @{

 

                                                                          Model=$regkey.GetValue('Model')

                                                                          Manufacturer=$regkey.GetValue('Manufacturer')

                                                                         }

     }

     Catch{

           Write-Host "$_"  -fore red

     }

 }

$results|Export-Csv C:\temp\PCs-Results.csv -NoType


Viewing all articles
Browse latest Browse all 6937

Trending Articles