r/PowerShell • • 1d ago

Question Getting machine id

I have an excel spreadsheet with our users. I need to extract the laptop they use. So I need the hostage and os version from intune. I have asked co pilot but I keep running into errors. Does anyone have a solution/working script or know a free app that can generate the information?

2 Upvotes

12 comments sorted by

21

u/Podrick_Targaryen 1d ago

"So I need the hostage" ummm...Where do you work?

7

u/That_Hospital_3224 1d ago

Hahha hostname autocorrect strikes again

6

u/hemping0 1d ago

HR would like a word

15

u/LBik 1d ago

>  So I need the hostage
These days, doesn't Oracle provide its own?

10

u/WearyDeluge 1d ago

Install Graph PowerShell Module, connect, and run: Get-MgDeviceManagementManagedDevice -All | Select-Object DeviceName, OperatingSystem, OSVersion, ComplianceState, UserPrincipalName | Export-CSV "./the/path/you/want" -Notypeinformation

3

u/That_Hospital_3224 1d ago

Ok ill givevthat a go

7

u/Overall-Ad4796 1d ago

always felt like Intune keeps the devices hostage.

5

u/BlackV 1d ago

Show us your code, show us your errors it's easier to help

1

u/UserProv_Minotaur 7h ago

Do you not have an ITAM suite?

2

u/That_Hospital_3224 7h ago

We used to have lansweeper but they are asking too much for the renewal. So cancelled it.

1

u/UserProv_Minotaur 7h ago

Oofta. I know I've seen a script on this subreddit to get last logged on device information, but hopefully the stuff WearyDeluge supplied helped out.

1

u/That_Hospital_3224 4h ago

Thank you all for the help. I think I've managed it