1

I'm trying to disable devices using Update-MgDevice. According to the documentation, -AccountEnabled should be a switch that accepts a boolean (true or false)

I can get the accountEnabled property status, whether true or false, using Get-MgDevice, but I can't seem to enable or disable using Update-MgDevice

Whether or not I use Update-MgDevice -AccountEnabled $True/'true'true or use Update-MgDevice -AccountEnabled $False/'false'/false I get the same error:

Update-MgDevice : A positional parameter cannot be found that accepts argument 'True'. or Update-MgDevice : A positional parameter cannot be found that accepts argument 'False'.

Am I just not understanding the switch properly?

iBowler
  • 13
  • 2
  • 1
    Have you tried AccountEnabled:$false? – bluuf Jan 25 '22 at 16:16
  • Good tip, @bluuf. iBowler, [`Update-MgDevice`](https://docs.microsoft.com/en-us/powershell/module/microsoft.graph.identity.directorymanagement/update-mgdevice?view=graph-powershell-beta)'s `-AccountEnabled` parameter is a _switch_ parameter, which means that _normally_ `-AccountEnabled` alone _implies_ `$true` and the _absence_ of the parameter implies `$false`. To pass a value _explicitly_ - which `Update-MgDevice` seemingly - and unfortunately - requires if you want to pass `$false` - you _must_ follow the parameter name with `:`, i.e. `-AccountEnabled: $false`. See the linked duplicate. – mklement0 Jan 25 '22 at 17:48

0 Answers0