\n Hi, and welcome to the PowerShell forum! \n\n\nDon’t apologize for being a “noob” or “newbie” or “n00b.” There’s just no need – nobody will think you’re stupid, and the forums are all about asking questions. Just ask!\nUse a descriptive subject. Don't say \"Need help\" or \"PowerShell Help\", actually summarize what the problem is. It helps the rest of us keep track of which problem is which.\nDon’t post massive scripts. We’re all volunteers and we don’t have time to read all that, nor will we copy, past…\n <\/blockquote>\n<\/aside>\n\n
<\/p>","upvoteCount":0,"datePublished":"2019-05-16T18:15:07.000Z","url":"https://community.spiceworks.com/t/power-shell-command/712359/2","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
You need to use $ for variables instead of @.<\/p>\n
$ADUserParams=@{ \n'Server' = server\n'Searchbase' = 'OU=sites,DC=xxxx,DC=xxxx' \n'Searchscope'= 'Subtree' \n'Filter' = '*' \n'Properties' = ('SAMAccountname','Employeenumber','givenname','surname','Division','title','EmailAddress')\n} \n\n$SelectParams=@{ \n'Property' = 'SAMAccountname','Employeenumber','givenname','surname','Division','title','EmailAddress',@{Name='Manager Last';Expression={(Get-ADUser $_.Manager).surname}},@{Name='Manager First';Expression={(Get-ADUser $_.Manager).givenname}},@{Name='Manager Clock';Expression={(Get-ADUser $_.Manager).Employeenumber}},'officephone',@{Name='Manager email';Expression={(Get-ADUser $_.Manager).EmailAddress}}\n} \n\nget-aduser $ADUserParams | select-object $SelectParams | export-csv \"c:\\temp\\test.csv\"\n<\/code><\/pre>\n-Properties * is inefficient, especially if you know which properties you want to retrieve.<\/p>","upvoteCount":2,"datePublished":"2019-05-16T18:20:23.000Z","url":"https://community.spiceworks.com/t/power-shell-command/712359/3","author":{"@type":"Person","name":"Evan7191","url":"https://community.spiceworks.com/u/Evan7191"}},{"@type":"Answer","text":"