I am trying to get the local users that are connected to a Microsoft account from my C# application.
PS C:\Users\MyUser> Get-LocalUser | Select Name, PrincipalSource
When I run this from cmd, I get the desired results. I tried to reproduce this in c#
using (PowerShell ps = PowerShell.Create())
{
ps.AddCommand("Get-LocalUser | Select Name, PrincipalSource");
foreach (PSObject pso in ps.Invoke())
{
if (pso.Members["PrincipalSource"].Value != null)
{
}
}
}
This will return the User name but not the PrincipalSource, there are no return errors