I have two VMs that were built using the same base image. Both have the same version of PowerShell and both have the same admin user. When I run Add-LocalGroupMember on one I get an the following error:
PS C:\Users\DevTraining> Add-LocalGroupMember -Group "Remote Desktop Users" -Member "Groovy-Ruby"
Add-LocalGroupMember : Object reference not set to an instance of an object.
At line:1 char:1
+ Add-LocalGroupMember -Group "Remote Desktop Users" -Member "Groovy-Ru ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-LocalGroupMember], NullReferenceException
+ FullyQualifiedErrorId : An unspecified error occurred.,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand
Both machines have ExecutionPolicy set to Unrestricted(for what it's worth). Both have the same system path and PowerShell is installed in the same location. I have tried running it in PowerShell ISE as Administrator. I have also tried running it in a script and the commandline(again FWIW). Surprisingly google as very little pertinent results. Here is the host information:
PS C:\Users\DevTraining> Get-Host
Name : Windows PowerShell ISE Host
Version : 5.1.17763.1971
InstanceId : 74eadbcd-818b-4302-89f6-8cab287a9bd7
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace