0

I obtained the BIOS data and saved it in HTML file but i don't want all the data to be in the file and i also need to format it so that it could suite my requirement.

Code:

$bios = get-wmiobject -class "Win32_BIOS" -namespace "root\CIMV2"
[string]$body = $bios | ConvertTo-Html -As List| Out-File c:/d/d/Test.htm
Cœur
  • 37,241
  • 25
  • 195
  • 267
Illuminati
  • 555
  • 2
  • 7
  • 34

2 Answers2

0

Try this:

$freeSpace = (gwmi Win32_logicaldisk -Filter "DeviceID = 'C:'").FreeSpace

gwmi Win32_BIOS `
  | select PSComputerName,Manufacturer,SerialNumber,Version,
      @{n="AvailableSpace";e={[int]($freeSpace / 1MB)}} `
  | ConvertTo-Html `
  | Out-File "C:/d/d/Test.htm"
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • i was referring to the harddisk space available i need all these to be in the html file – Illuminati Jul 15 '13 at 18:49
  • $disk = ([wmi]"\root\cimv2:Win32_logicalDisk.DeviceID='c:'") "Amount of Free Space C: has {0:#.0} GB Total" -f ($disk.FreeSpace/1GB)| write-output i need this data also to be included in the html file along with the other data – Illuminati Jul 15 '13 at 18:50
  • Added free disk space calculation. – Ansgar Wiechers Jul 15 '13 at 19:10
  • works great just out of curiosity if there are many drives then how do we go by ? as in this case we are confining it to just C drive. I truly appreciate your effort thank you soo much for your support. – Illuminati Jul 15 '13 at 19:22
  • You really shouldn't ask someone for more help when you just unaccepted their answer. – Ansgar Wiechers Jul 15 '13 at 19:26
  • i never said i did not accept the answer :( just out of curiosity i asked it – Illuminati Jul 15 '13 at 19:42
0

So based on the discussion in the comments, I think you are looking for something like this:

function GetCompInfoWork 
{
   param (
     [string]$computername,[string]$logfile
     )
    $os = Get-WmiObject win32_operatingsystem -ComputerName $computername
    $bios = Get-WmiObject win32_bios -ComputerName $computername
    $disk = Get-WmiObject win32_logicalDisk -Filter "DeviceID= 'C:'" `
    -computername $computername

    $obj = New-Object -TypeName PSObject

    $obj | Add-Member -MemberType NoteProperty `
        -Name ComputerName -Value ($os.csname)
    $obj | Add-Member -MemberType NoteProperty `
        -Name Manufacturer -Value ($bios.manufacturer)
    $obj | Add-Member -MemberType NoteProperty `
        -Name SysDriveFree -Value ($disk.freespace / 1GB -as [int])
    $obj | Add-Member -MemberType NoteProperty `
        -Name SerialNumber -Value ($bios.serialnumber)
    $obj | Add-Member -MemberType NoteProperty `
        -Name Version -Value ($bios.version)            
    Write-Output $obj
}
function Get-CompInfo 
{
  param ([string[]]$computername,[string]$logfile )

  BEGIN
  {
    $usedParamater = $False
    if ($PSBoundParameters.ContainsKey('computername')) {
        $usedParamater = $True
        }
  }
  PROCESS {
    if ($usedParamater) 
    {
        foreach ($computer in $computername)
        {
            Getcompinfowork -computername $computer `
            -logfile $logfile
        }
    }          
    else 
    {
        Getcompinfowork -computername $_ `
        -logfile $logfile
    }

  }
  END {}
}

Get-CompInfo -computername localhost | ConvertTo-Html | Out-File C:\Output.html
Kevin_
  • 2,916
  • 3
  • 19
  • 18
  • FreeSpace : 16455 Size : 25454 this is shown by my $disk but my output file shows following data SysDriveSpace SysDriveFree 0 158 why is this discrepancy – Illuminati Jul 15 '13 at 19:06
  • Thank you sooo much for your help it was quite handy :) – Illuminati Jul 15 '13 at 19:22
  • @user2540455 Glad I can help. I use something similar to this script at work. I just modified it to meet your criteria. Did you figure out the disk space discrepancy? – Kevin_ Jul 15 '13 at 20:14
  • I am not having any problems with it. Try just running the command: Gwmi win32_logicaldisk -filer "deviceID= 'C:'" | select {$_.freespace / 1GB -as [int]} – Kevin_ Jul 15 '13 at 21:07
  • i thought i can make 2 answers as correct just now came to know that i can do only for one :) and one more doubt how do we find the max ram a computer can be fitted with – Illuminati Jul 15 '13 at 21:22
  • hmm.. thats a tricky one. You can use the win32_physicalmemory class, but it lists the capacity of each DIMM slot. I suppose it could be looped through to add up the capacity of each dimm. – Kevin_ Jul 15 '13 at 21:30