Well I thought this might be an interesting one to start the New Year off....or not for some

. I am gonna post a function below from my pshell profile that I work from. It's not finished yet but any improvments or suggestions always welcome. Maybe others can do the same!
function GETPCINFO {
$cred = Get-Credential
$computers = Get-Content "C:\scripts\computers.txt"
foreach ($computer in $computers)
{
#### Set Variables
$user = $env:USERNAME
#### Win32 class short name assignment - add -credential $cred where needed
$OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computer
$Bios = Get-WmiObject -Class Win32_BIOS -ComputerName $computer
$CS = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer
$CPU = Get-WmiObject -Class Win32_Processor -ComputerName $computer
$HDDSC = Get-WmiObject -Class Win32_LogicalDisk -ComputerName $computer -Filter "name='C:'"
#### Set Variable information with short name
$OSRunning = $OS.caption + " " + $OS.OSArchitecture + " SP " + $OS.ServicePackMajorVersion
$DomainRole = $CS.DomainRole
$TotalAvailMemory = $OS.totalvisiblememorysize/1kb
$TotalVirtualMemory = $OS.totalvirtualmemorysize/1kb
$TotalFreeMemory = $OS.FreePhysicalMemory/1kb
$TotalFreeVirtualMemory = $OS.FreeVirtualMemory/1kb
$TotalMem = "{0:N2}" -f $TotalAvailMemory
$TotalVirt = "{0:N2}" -f $TotalVirtualMemory
$FreeMem = "{0:N2}" -f $TotalFreeMemory
$FreeVirtMem = "{0:N2}" -f $TotalFreeVirtualMemory
$date = Get-Date
$uptime = $OS.ConvertToDateTime($OS.lastbootuptime)
$BiosVersion = $Bios.Manufacturer + " " + $Bios.SMBIOSBIOSVERSION + " " + $Bios.ConvertToDateTime($Bios.Releasedate)
$CPUInfo = $CPU.Name + " & has " + $CPU.NumberOfCores + " Cores & the FSB is " + $CPU.ExtClock + " Mhz"
$CPULOAD = $CPU.LoadPercentage
echo "#### INFO FOR $computer which is running $OSRunning#### `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt"
if (($DomainRole -eq "0") -or ($DomainRole -eq "1"))
{
echo "This system is a Workstation. `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
}
elseif (($DomainRole -eq "2") -or ($DomainRole -eq "3"))
{
echo "This system is a Member Server. `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
}
elseif (($DomainRole -eq "4") -or ($DomainRole -eq "5"))
{
echo "This system is a Domain Controller. `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
}
else
{
echo "Unknown System Type. `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
}
echo "######## Memory Information ######## `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "Total Physical Memory = $TotalMem MB / Total Free Physical Memory = $FreeMem MB" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "Total Virtual Memory = $TotalVirt MB / Total Free Virtual Memory = $FreeVirtMem MB `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "######## Last Boot Time for this PC ######## `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "Last Boot Time $uptime `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "######## Bios Version ######## `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "The Bios Version is $BiosVersion `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "######## CPU INFO ########`n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "The CPU is a $CPUInfo `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "The CPU Load Percentage for the last minute of activity is $CPULOAD % `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "######## HDD Partition Information ######## `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
### Need way of reducing code for following ###
$freec = [Math]::Round($HDDSC.freespace/1gb)
$sizec = [Math]::Round($HDDSC.size/1gb)
echo "C: `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "Total Space: $sizec GB" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "Free Space: $freec GB `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
echo "######## Installed Software ######## `n" | Out-File "C:\Scripts\SERVERINFO\$computer.txt" -Append
}
}
I will probably move the output to excel at some point, when I have everything there I need. PS. The get credential is not being used at the moment coz I am testing on a local machine running shell as admin, so it is not required.