I'm trying to get the Username from Get-AppxPackage. Unfortunately that property is nested quite deep. In my head it would be something like this (but it doesn't work):
Get-AppxPackage -Allusers | select $_.PackageUserInformation.UserSecurityID.Username | where-object {$_.PackageUserInformation.UserSecurityID.UserName -notlike "defaultuser*"}
In UserName, there could be either 1 or 2 items depending on the package. If there are 2 items, I want to put the one that is not like 'defaultuser*' into a variable as a string.
Running Get-AppxPackage -Allusers | where-object {$_.PackageUserInformation.UserSecurityID.UserName -like "defaultuser*"}
Should return some example packages with multiple UserName items that are built into Windows 10.