PS script to get Windows 10 clients name and win version, and also get the last logged in SamAccountName on clients and export all into excell.xlmx document

Hi,

I hope someone inhere can help me designing af powershell script which does the following:

 

1) - Find all windows 10 clients in AD, and get thier windows version.

Then also get the either SamAccountName OR last SamAccountName logged in on the found windows 10 clients!

2) - Export Last login "SamAccountName", "OperationSystem" and "OperationSystemVersion" to an excell document.

 

I have the following code sofar:

 

Import-Module ActiveDirectory

Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,OperatingSystemVersion | Export-CSV C:\AllWindows1.csv -NoTypeInformation -Encoding UTF8

 

But i need this to fetch the logged in/last login of the SamAccountName also on the windows 10 clients in the AD, and also export this to an excell.xlmx, if possible.

Can anyone help me?

Best regards

Parents
  • Hi, i have tried to work out a script myself, where i get some of the info needed.
    But i need some extra code help now.

    Current script:

    Import-Module ActiveDirectory
    Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,OperatingSystemVersion | Export-CSV C:\AllWindows1.csv -NoTypeInformation -Encoding UTF8

    I would really like the following to be added to the script:

    1) Only get windows 10 clients, with the Notlike command?.
    2) Get the *Last logged on* on the found clientlist also, and display this in the Export also.

    Can anyone help me??
Reply Children
No Data