power shell result in one line.

Welcome Forums General PowerShell Q&A power shell result in one line.

This topic contains 1 reply, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #66990

    Points: 0
    Rank: Member

    $computerSystem = Get-CimInstance CIM_ComputerSystem
    $computerBIOS = Get-CimInstance CIM_BIOSElement
    $computerOS = Get-CimInstance CIM_OperatingSystem
    $computerCPU = Get-CimInstance CIM_Processor
    $computerHDD = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID = 'C:'"
    Hello, I am trying to have all the pc information in one line. What should I modify to get it in one line likened then save it as CSV.

    Manufacturer, Model, Serial Number, CPU,HDD Capacity, HDD Space, etc...

    Write-Host "System Information for: " $computerSystem.Name -BackgroundColor DarkCyan
    "Manufacturer: " + $computerSystem.Manufacturer
    "Model: " + $computerSystem.Model
    "Serial Number: " + $computerBIOS.SerialNumber
    "CPU: " + $computerCPU.Name
    "HDD Capacity: " + "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
    "HDD Space: " + "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size) + " Free (" + "{0:N2}" -f ($computerHDD.FreeSpace/1GB) + "GB)"
    "RAM: " + "{0:N2}" -f ($computerSystem.TotalPhysicalMemory/1GB) + "GB"
    "Operating System: " + $computerOS.caption + ", Service Pack: " + $computerOS.ServicePackMajorVersion
    "User logged In: " + $computerSystem.UserName
    "Last Reboot: " + $computerOS.LastBootUpTime

    if I run it i am getting it like:
    System Information for: pc-name
    Manufacturer: Dell Inc.
    Model: OptiPlex 7010
    Serial Number: 647ZXX1
    CPU: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
    HDD Capacity: 146.39GB
    HDD Space: 6.15 % Free (9.00GB)
    RAM: 7.89GB
    Operating System: Microsoft Windows 7 Professional , Service Pack: 1
    User logged In:
    Last Reboot: 03/19/2017 08:16:21

  • #67003

    Points: 157
    Helping Hand
    Rank: Participant

    Output your data as a PSObject not text. See this script as an example..

The topic ‘power shell result in one line.’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort