Hi ,
This script u provide is showing error.
Script is as :
foreach ($ComputerNamein (Get-Content-PathC:\servers.txt)){ $hostname=Get-WmiObjectWin32_Computersystem-ComputerName$ComputerName | Select-Object-ExpandPropertyName$disks=Get-WmiObjectWin32_LogicalDisk | foreach { "$($_.DeviceID) : $($_.FreeSpace / 1GB ) GB" } $Os=Get-WmiObject-ComputerName$ComputerName-ClassWin32_OperatingSystem$lastBoot=$os.ConvertToDateTime($os.LastBootUpTime) $uptime=New-TimeSpan-Start$lastBootNew-Object-TypeNamepsObject-Property @{ Hostname =$hostname Disks =$disks Uptime =$Uptime } }
Error :
Unexpected token 'Disks' in expression or statement.
At line:1 char:575
+ foreach ($ComputerName in (Get-Content -Path C:\servers.txt)){ $hostname = Get-WmiObject Win32_Computersystem -Com
puterName $ComputerName | Select-Object -ExpandProperty Name $disks = Get-WmiObject Win32_LogicalDisk | forea
ch { "$($_.DeviceID) : $($_.FreeSpace / 1GB ) GB" } $Os = Get-WmiObject -ComputerName $ComputerName -C
lass Win32_OperatingSystem $lastBoot = $os.ConvertToDateTime($os.LastBootUpTime) $uptime = New-TimeSpan -Start $
lastBoot New-Object -TypeName psObject -Property @{ Hostname = $hostname Disks <<<< = $disks
Uptime = $Uptime } }
+ CategoryInfo : ParserError: (Disks:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken