Export computers to a file with power shell

  • 353 Views
  • Last Post 10 October 2018
adriaoramos posted this 30 June 2018

I need to list all my computers with last boot time. I found  a good tip like this: "Get-ADCodownloadmputer -Filter * -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap –Auto" , However I didnt find a way to get the latest boot time and set a specified OU. Is ther a way to do that, adding those options to the command?

Adriao Ferreira Ramos
Equipe de infraestrutura
Departamento de Operações e Infraestrutura - CII
tel
+55 11 3388-8193
adriaoramos@xxxxxxxxxxxxxxxx
imprimir sabesp sp face twiter youtube




Order By: Standard | Newest | Votes
michael1 posted this 05 July 2018

Get-WmiObject win32operatingsystem | select CSName, LastBootUptime

 

Or

 

WMIC PATH Win32
OperatingSystem Get CSName,LastBootUpTime

 

show

saikri77 posted this 10 October 2018

You cannot get last boot time from AD data as it is not registered there. However you can try for lastlogontimestamp. Which should give relatively closer one.

bshwjt posted this 10 October 2018

Hi,
Last boot time is not stored in AD. You could try something like that.
$DCs =  [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().domains.DomainControllers.Name foreach ($DC in $DCs){ [PSCustomObject]@{        ComputerName = $DC        Lastbootuptime =  Get-WinEvent -ComputerName $DC -ErrorAction Stop -FilterHashtable @{logname=’System'; id=1074} -MaxEvents 1 | Select-Object -ExpandProperty TimeCreated              }                 }
Thanks
On Wed, 10 Oct 2018 at 08:30, <saikrishna.nagisetti@xxxxxxxxxxxxxxxx> wrote:




You cannot get last boot time from AD data as it is not registered there. However you can try for lastlogontimestamp. Which should give relatively closer one.

show

daemonr00t posted this 10 October 2018

The old faithful systeminfo with a  for loop can do the trick too.

Anyway, in the backend it is WMI…

https://blogs.technet.microsoft.com/heyscriptingguy/2013/03/27/powertip-get-the-last-boot-time-with-powershell/



 

~danny





 






show

sajeed posted this 10 October 2018

Thank you


show

Close