Hello,
Suite à cette question postée sur le forum TechNet, voici la fonction tirée du script que j’ai proposé en réponse :
function Get-ComputerInfo { <# .SYNOPSIS Get hardware information of a given computer .DESCRIPTION This function allows you to find basic hardware information of a given computer .PARAMETER Computer Specify the target computer for the WMI queries .EXAMPLE Get-ComputerInfo -Computer PC001 .Notes Author : Antoine DELRUE WebSite: https://obilan.be #> [cmdletbinding()] Param([string[]]$Computer) # Creating an empty array, will be used later $array= @() try { # Creating and populating the array $Object = New-Object PSObject $Object | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value (Get-WmiObject -Class win32_computersystem -ComputerName $computer).Name $Object | Add-Member -MemberType NoteProperty -Name "Brand" -Value (Get-WmiObject -Class win32_computersystem -ComputerName $computer).Manufacturer $Object | Add-Member -MemberType NoteProperty -Name "Model" -Value (Get-WmiObject -Class win32_computersystem -ComputerName $computer).Model $Object | Add-Member -MemberType NoteProperty -Name "RAM" -Value ((Get-WmiObject -Class win32_computersystem -ComputerName $computer).TotalPhysicalMemory/1Gb) $Object | Add-Member -MemberType NoteProperty -Name "OS" -Value (Get-WmiObject -Class win32_operatingsystem -ComputerName $computer).Caption $Object | Add-Member -MemberType NoteProperty -Name "CPU" -Value (Get-WmiObject -Class Win32_processor -ComputerName $computer).Name $Object | Add-Member -MemberType NoteProperty -Name "LoggedOnUsers" -Value (Get-WmiObject -Class win32_computersystem -ComputerName $computer).Username $array += $Object } catch { Write-Error -Message "The command failed for computer $computer. Message: $_.Exception.Message" break } # Now displaying the result $array }
L’utilisation de la fonction est très simple, il suffit de fournir le nom d’un PC au paramètre -Computer :
get-computerinfo -computer dc01
Et voici le résultat obtenu :
Voilà, j’espère que cela peut aider !