PowerShell Function Comma List and Text File

email me

Function Get-CompSysInfo {
     param(
     [string[]]$ComputerName
)
     BEGIN {}
     PROCESS {
         if ($_ -ne $null) {
         $ComputerName = $_
         }
           
           #foreach used for comma list
           foreach ($computer in $ComputerName) {
            #returns info on computer - could be another wmi object     
            get-wmiobject -Class win32_computersystem -ComputerName $Computer |
               Select-Object -Property Name,Manufacturer,Model
          }
     }
     END {}
}

# from comma list
# Get-CompSystemInfo -ComputerName PC_1, PC_2, PC_3

# from text file
Get-Content C:\Computerlist.txt | Get-CompSysInfo