Another rookie mistake I expect. I’m running the following and it works without error and I’ve a longer script that runs perfectly as well. However, on some occasions I just want to check up on someones line manager so I wrote this:<\/p>\n

Get-ADUser x | Select SamAccountName,Enabled,@{N=\"Manager\";E= {%{(Get-AdUser $_.Manager).Name}}}\n\n<\/code><\/pre>\n

Advertisement

Which returns, a blank manager. Thoughts?<\/p>\n

SamAccountName Enabled Manager\n-------------- ------- -------\nx                True        \n<\/code><\/pre>","upvoteCount":2,"answerCount":6,"datePublished":"2018-03-02T16:45:45.000Z","author":{"@type":"Person","name":"michaelcoyle","url":"https://community.spiceworks.com/u/michaelcoyle"},"acceptedAnswer":{"@type":"Answer","text":"
\n
\n
<\/div>\n\"\" Neally:<\/div>\n
\n
\n
\n
<\/div>\n\"\" babayagaa:<\/div>\n
\n
@{N=\"Manager\";E= {%{(Get-AdUser $_.Manager).Name}}}\n<\/code><\/pre>\n

Advertisement

Thoughts?<\/p>\n<\/blockquote>\n<\/aside>\n

Why do you use % rather than foreach ? ( da rulz<\/a> )<\/p>\n

You can not have multiple managers AFAIK, so that part seems redundant.<\/p>\n<\/blockquote>\n<\/aside>\n

This is my piece of Code, I posted last time an answer, and most of the time I post alias \":stuck_out_tongue:\" blame me:p<\/p>\n

If you frequently need to query users manager better try this Not tested, just wrote pain in code<\/p>\n

Function Get-Manager {\nParam($user)\nIf(-not($user))\n{\nWrite-Warning \"Please supply user Name\"\n}\nGet-ADUser -user $user -Properties Manager  | \nSelect SamAccountName,Enabled,@{N=\"Manager\";E={(Get-AdUser $_.Manager).Name}}\n}\n<\/code><\/pre>\n

Just run the above script and you can run<\/p>\n

Get-Manager -user jack\n<\/code><\/pre>\n

you just need to run get-manager -user and username next time, Hopefully it works<\/p>","upvoteCount":1,"datePublished":"2018-03-02T17:53:35.000Z","url":"https://community.spiceworks.com/t/split-dn-reporting-blank/638066/4","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},"suggestedAnswer":[{"@type":"Answer","text":"

Another rookie mistake I expect. I’m running the following and it works without error and I’ve a longer script that runs perfectly as well. However, on some occasions I just want to check up on someones line manager so I wrote this:<\/p>\n

Get-ADUser x | Select SamAccountName,Enabled,@{N=\"Manager\";E= {%{(Get-AdUser $_.Manager).Name}}}\n\n<\/code><\/pre>\n

Which returns, a blank manager. Thoughts?<\/p>\n

SamAccountName Enabled Manager\n-------------- ------- -------\nx                True        \n<\/code><\/pre>","upvoteCount":2,"datePublished":"2018-03-02T16:45:45.000Z","url":"https://community.spiceworks.com/t/split-dn-reporting-blank/638066/1","author":{"@type":"Person","name":"michaelcoyle","url":"https://community.spiceworks.com/u/michaelcoyle"}},{"@type":"Answer","text":"

You are missing the property for the manager<\/p>\n

Get-ADUser $username -Properties Manager  | \nSelect SamAccountName,Enabled,@{N=\"Manager\";E= {(Get-AdUser $_.Manager).Name}}\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2018-03-02T17:14:20.000Z","url":"https://community.spiceworks.com/t/split-dn-reporting-blank/638066/2","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
\n
\n
<\/div>\n\"\" babayagaa:<\/div>\n
\n
@{N=\"Manager\";E= {%{(Get-AdUser $_.Manager).Name}}}\n<\/code><\/pre>\n

Thoughts?<\/p>\n<\/blockquote>\n<\/aside>\n

Why do you use % rather than foreach ? ( da rulz<\/a> )<\/p>\n

You can not have multiple managers AFAIK, so that part seems redundant.<\/p>","upvoteCount":2,"datePublished":"2018-03-02T17:18:20.000Z","url":"https://community.spiceworks.com/t/split-dn-reporting-blank/638066/3","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"

\n
\n
<\/div>\n\"\" JitenSh:<\/div>\n
\n

I post alias<\/p>\n<\/blockquote>\n<\/aside>\n

\"giphy.gif\"<\/p>","upvoteCount":1,"datePublished":"2018-03-02T18:29:35.000Z","url":"https://community.spiceworks.com/t/split-dn-reporting-blank/638066/5","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"

\n
\n
<\/div>\n\"\" JitenSh:<\/div>\n
\n
\n
\n
<\/div>\n\"\" Neally:<\/div>\n
\n
\n
\n
<\/div>\n\"\" babayagaa:<\/div>\n
\n
@{N=\"Manager\";E= {%{(Get-AdUser $_.Manager).Name}}}\n<\/code><\/pre>\n

Thoughts?<\/p>\n<\/blockquote>\n<\/aside>\n

Why do you use % rather than foreach ? ( da rulz<\/a> )<\/p>\n

You can not have multiple managers AFAIK, so that part seems redundant.<\/p>\n<\/blockquote>\n<\/aside>\n

This is my piece of Code, I posted last time an answer, and most of the time I post alias \":stuck_out_tongue:\" blame me:p<\/p>\n

If you frequently need to query users manager better try this Not tested, just wrote pain in code<\/p>\n

Function Get-Manager {\nParam($user)\nIf(-not($user))\n{\nWrite-Warning \"Please supply user Name\"\n}\nGet-ADUser -user $user -Properties Manager  | \nSelect SamAccountName,Enabled,@{N=\"Manager\";E={(Get-AdUser $_.Manager).Name}}\n}\n<\/code><\/pre>\n

Just run the above script and you can run<\/p>\n

Get-Manager -user jack\n<\/code><\/pre>\n

you just need to run get-manager -user and username next time, Hopefully it works<\/p>\n<\/blockquote>\n<\/aside>\n

I’ve bastardised so much of your code JitenSh. Can’t thank you enough! I swear I’m making process, the last few weeks have been rough (new job) but you’ve been incredibly helpful. Thank you again!<\/p>\n

And thank you all. Appreciate all of the assistance!<\/p>","upvoteCount":0,"datePublished":"2018-03-02T22:10:00.000Z","url":"https://community.spiceworks.com/t/split-dn-reporting-blank/638066/6","author":{"@type":"Person","name":"michaelcoyle","url":"https://community.spiceworks.com/u/michaelcoyle"}}]}}