I have a name of an employee For eg: "XYZ". Now i want to get its login name using script. I have tried like this:
$user='XYZ'
$userName=$web.EnsureUser[$user]
But i m getting $userName null
Thanks
EnsureUser
is a method, and you are using it as an indexer. Change $userName=$web.EnsureUser[$user]
to $userName=$web.EnsureUser($user)
To get user login user below given command
$user='XYZ'
$userName=$web.EnsureUser($user).UserLogin