0

I'm using Power Shell script to get user.

I have include the Domain name in EnsureUser - Domain\Username

Please check below code.

$AuthorLoginName = "domain\akshay"
try{
[Microsoft.SharePoint.SPUser]$Author = $w.EnsureUser($AuthorLoginName)  }
catch
{}

Please suggest some workaround

4
  • tried i:0#.w|domain\akshay ? Commented Jan 24, 2017 at 9:26
  • Are you using claims? Commented Jan 24, 2017 at 9:26
  • @GautamSheth let me try! Commented Jan 24, 2017 at 9:33
  • cool ! will be adding it as answer :) Commented Jan 24, 2017 at 17:24

1 Answer 1

2

You need to use i:0#.w|domain\akshay as input.

So try below code:

$AuthorLoginName = "i:0#.w|domain\akshay"
try{
[Microsoft.SharePoint.SPUser]$Author = $w.EnsureUser($AuthorLoginName)  }
catch
{}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.