First we connect to Azure AD, I’m going to use the MSOnline module:
connect-msoldevice
Then we get the computers and export them to a CSV file.
get-msoldevice -All | select-object DisplayName, Enabled, ApproximateLastLogonTimestamp | Export-csv –NoTypeInformation 'c:\data\azuredevicedetails.csv'
Which gives us this output:
NODDY53 |
CN=NODDY53,OU=LabComputers,OU=ANOTHEROUGOESHERE | Fred’s work computer | Windows 7 enterprise | 3/6/2019 9:36 |
---|---|---|---|---|
BILBO | CN=BILBO,OU=SERVERS,OU=ETC | WSUS SERVER | WINDOWS 2016 | 5/12/2019 16:31 |
DAVO | CN=DECOMMISIONED | WAS DECOMMED IN 2021 | WINDOWS 10 PRO | 23/10/2021 14:40 |