$user = Get-SPuser -Web $web -Identity $UserID
Get-SPUser : You must specify a valid user object or user identity.
At line:11 char:31
+ $user = get-SPuser <<<< -Web $web -Identity $UserID
+ CategoryInfo : InvalidArgument: (Microsoft.Share....SPUserPipeBind:SPUserPipeBind) [Get-SPUser], PSArgumentException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetUser
$user = $web.EnsureUser($username)
Exception calling "EnsureUser" with "1" argument(s): "The specified user Krishna could not be found."
How can I verify User exists in a site or not?
How can I fetch users without any exceptions?
If user doesn't exists, add user in site and fetch user.