$PCs = Get-Content -Path "P:\scripts\PCs.txt"
$local = Get-Credential administrator
$results = @{}
$results = foreach ($PC in $PCs)
{
if (Test-Connection -ComputerName $PC -Count 1 -Quiet)
{
Write-Verbose "Working on $PC"
$bios = Get-WmiObject Win32_BIOS -ComputerName $PC -Credential $local
$Proc = Get-WmiObject Win32_processor -ComputerName $PC -Credential $local | Select-Object -First 1
$memory = Get-WmiObject Win32_physicalmemory -ComputerName $PC -Credential $local | Select *
$system = Get-WmiObject Win32_ComputerSystem -ComputerName $PC -Credential $local
$os = Get-WmiObject Win32_OperatingSystem -ComputerName $PC -Credential $local
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $PC -Credential $local | ? {$_.IPEnabled}
$logonServer = Get-WmiObject -Class win32_ntdomain -Filter "DomainName = 'Corp'" -ComputerName $pc -Credential $local
$Mem = [math]::round($PC.TotalPhysicalMemory/1024/1024/1024, 0)
[PSCustomObject]@{
"PC Name" = $os.csname
InstallDate = $os.ConvertToDateTime($os.installDate)
"OS Version" = $os.Caption
OSArchitecture =$os.OSArchitecture
UserName = $system.UserName
Domain = $system.Domain
Manufacturer = $system.Manufacturer
Model = $system.Model
Memory = $System.TotalPhysicalMemory | where-Object {$_.freespace / 1MB}
SerialNumber = $Bios.SerialNumber
"Processor Name" = $proc.Name
"Processor Manufacturer" = $proc.Manufacturer
"Processor Max Clock Speed" = $proc.MaxClockSpeed
"CPU hardware 32 or 64" = $Proc.AddressWidth
IPAddress = $networks.IpAddress[0]
SubnetMask = $Networks.IPSubnet[0]
DefaultGateway = $Networks.DefaultIPGateway | Where-Object {$_}
"DNS Servers" = $Networks.DNSServerSearchOrder | Where-Object {$_}
"Logon Server" = $LogonServer.DomainControllerName
Mem = $system.[math]::round($PC.TotalPhysicalMemory/1024/1024/1024, 0)
}
}
}
$results | format-list
I found this example and tested and works fine and memory shows as 8 GB
$x = read-host -prompt "Please enter the machine name: "
$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "root\CIMV2" -computername $x
foreach ($objItem in $colItems){
$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)
write-host "Total Physical Memory: " $displayGB "GB"
write-host "Model: " $objItem.Model
}
$colItems = get-wmiobject -class "Win32_Processor" -namespace "root\CIMV2" -computername $x
foreach ($objItem in $colItems){
write-host "System Name: " $objItem.SystemName
}