Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Want to add more fields

$
0
0

Hi ,

the below scripts is working fine now i want to add some more fields in it like

Host Name , Model Number , Drivers (like c,d with there space and how much is used )

 

plz help me with this

 

 

$servers = Get-Content C:\Servers.txt
foreach ($s in $servers)
{
try
{
$a=Get-WmiObject -ComputerName $s -Class Win32_OperatingSystem -ErrorAction ‘Stop’
$b = $a.convertToDateTime($a.Lastbootuptime)
[TimeSpan]$LastBoot = New-TimeSpan $b $(Get-Date)
(‘{0} {1}Day(s),{2}Hour(s),{3}Min(s),{4}Seconds’ -f $s,$LastBoot.Days,$lastboot.Hours,$LastBoot.Minutes,
$LastBoot.Seconds)

| out-file C:\UptimeReport.txt -append -Encoding ascii

Catch
{
(‘{0} Server is notreachable’ -f $s)| Out-File C:\offline.txt -Append -Encoding ascii
}
}


Viewing all articles
Browse latest Browse all 8583

Latest Images

Trending Articles



Latest Images