The computer where the script is executing is in the one domain, I'll call it internal domain. Users which are tested are in the other (external) domain.
I made a script to check if user exist in both domains. Here is a snippet from the script which doesn't cause the problem.
$domain = ‘domain.com’;
$user = ‘username’;
$objuser = New-Object System.Security.Principal.NTAccount($domain, $user);
$objUser.Translate([System.Security.Principal.SecurityIdentifier]) > $nil;
Before I tried executing the third line like this which caused the problems:
$objuser = New-Object System.Security.Principal.NTAccount('username@domain.com');
The problem I'm having right now is that some users from external domain are not shown properly in Windows.
The good example is file properties security tab. The user is shown as
DOMAIN\username@domain.com instead of just DOMAIN\username
This causes all sorts of weird things, such as users who want to access that folder to lose permissions on it.
Is there a way to get the normal behavior back? Restarting the machine is not an option unfortunately.