Hi Team,
Wrote a short script. Which pull out some hardware details. I am trying to save the output text / html file with basic formatting.
Following is the script what I wrote.
#Hardware Check ##CPU $proc=Get-CimInstance -ClassName CIM_processor |select Name, MaxclockSpeed, NumberofCores ##Memory $mem=Get-CimInstance -ClassName CIM_physicalmemory | select Caption,Manufacturer, @{n="Size(GB)"; e={$_.capacity /1GB}},ConfiguredClockSpeed ##HDD $Hdd=Get-CimInstance -ClassName CIM_logicaldisk| select DeviceID, @{n="TotalSize"; e={$_.Size /1GB -as[int]}} ##Operating System $os=Get-CimInstance -ClassName CIM_OperatingSystem|select Caption, OSArchitectureI am trying to run it by .\myscRipt.ps1 > myOutput.txt You can try and see what is the output style. The issue I am facing; headings which I want to put (which is mentioned after write-host)is not redirecting to the text file. Also, there are too many extra spaces which I don't like. Following is the output I am expecting. I manually edit the contents before posting here but need this type of output using the script.#Output
Write-Host “Hardware Summary:”
Write-Host CPU
$proc |FLWrite-Host Memory
$mem |flWrite-Host HardDisk
$Hdd |flWrite-Host operating System
$os |fl
Hardware Summary: CPU: Name : Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz MaxclockSpeed : 2400 NumberofCores : 2Memory:
Caption : Physical Memory
Manufacturer : Samsung
Size(GB) : 8
ConfiguredClockSpeed : 1600Harddisk:
DeviceID : C:
TotalSize : 464Operating System:
Caption : Microsoft Windows 10 Enterprise
OSArchitecture : 64-bit
This is the story. Need your valuable guidance to rectify the issue. Please help me to figure out what mistakes I am doing. And also suggest me what should I write into the script which saves the output directly to a file. Once I execute the file will be automatically created in some place/desktop.
Regards,
Sankha.