Why Can’t I Use Variables with Get-MgDevice and Get-MgDeviceManagementManagedDevice Cmdlets?

0
5
Asked By TechWizard88 On

Hey everyone! I'm running into a bit of a wall here. I've been trying to pass variables to the Get-MgDevice and Get-MgDeviceManagementManagedDevice cmdlets, but it just isn't working. I've included screenshots that show the $id variable I'm trying to use. Despite uninstalling and reinstalling Graph and my modules multiple times, I'm still stuck. Does anyone have any ideas or insights on what might be going wrong?

1 Answer

Answered By ScriptNinja42 On

You might need to expand the variable when using it. Try piping your command like this: `get-.... | Select-Object -ExpandProperty Id`. That should simplify things and just give you the ID as a result.

CodeMaster23 -

Also, great tip! Using ExpandProperty really saved me there. Thanks a bunch!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.