r/PowerShell • • Oct 12 '26

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?

5 Upvotes

15 comments sorted by

20

u/Podrick_Targaryen Oct 12 '26

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

8

u/That_Hospital_3224 Oct 12 '26

Hahha hostname autocorrect strikes again

6

u/hemping0 Oct 12 '26

HR would like a word

14

u/WearyDeluge Oct 12 '26

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 Oct 12 '26

Ok ill givevthat a go

2

u/That_Hospital_3224 Oct 13 '26

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

1

u/BlackV Oct 14 '26

what was your solution?

2

u/That_Hospital_3224 Oct 16 '26

I extracted the users we have from our hr portal. Then in intune I extracted all the devices. They all have a primary user. So I imported the list in excel and matched the names against the hr list. And excluded all the unmatched. It wasn't 100%. But 80% was good enough. The remainder i populated manually. Also I got AI to do all the heavy lifting. Took a few prompts, but for there in the end.

→ More replies (1)

18

u/LBik Oct 12 '26

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

7

u/Overall-Ad4796 Oct 12 '26

always felt like Intune keeps the devices hostage.

5

u/BlackV Oct 12 '26

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

1

u/UserProv_Minotaur Oct 13 '26

Do you not have an ITAM suite?

2

u/That_Hospital_3224 Oct 13 '26

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

1

u/UserProv_Minotaur Oct 13 '26

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.