2

I'm looking for some help as to why this is happening:

Get-ADComputer -filter * -SearchBase "OU=x,OU=xx,OU=xxx,DC=xxx,DC=com" -Properties * 

Does not show the "Company" attribute for a computer. However, if I run:

Get-ADComputer -filter * -SearchBase "OU=x,OU=xx,OU=xxx,DC=xxx,DC=com" -Properties * | select name, company, location

The company attribute does show up. I'm trying to update the company attribute, but I assume it's not letting my because the attribute is not listed under -properties*.

Set-ADComputer : A parameter cannot be found that matches parameter name 'company'.      
0

You can use the -Replace (and -Add,-Remove,-Clear) parameters for attributes that don't have direct setter methods:

PS C:\> Get-ADComputer pc4711 |Set-ADComputer -Replace @{company='Evil Corp'}
PS C:\> Get-ADComputer pc4711 -Properties * |Select-Object name,company

name   company
----   -------
pc4711 Evil Corp

-Replace works both for objects with and without existing values. -Add would result in an error for objects with existing values, since the attribute Company can hold only a single value.

| improve this answer | |
  • Thank you, I was able to use this method to update the company attribute! – Powershell_Help Aug 14 at 18:36
  • Can you reference in Microsoft documentation where it says you can use this? – Christopher H Aug 16 at 19:15
  • @Gerald Schneider good catch .. +1 from me ...microsoft is confising at times.. anyway good one. cheers. – Aravinda Aug 17 at 0:07
2

According to here and here, the parameter company is not a valid parameter for computer accounts.

| improve this answer | |
  • I can get behind that part, but why would I be able to see the company attribute by adding a " | select company" piece into the line when it wasn't originally listed with all the other properties? I was under the impression that what you could use a select statement for was limited to the items from your link. – Powershell_Help Aug 13 at 23:03
  • What version of Windows Server are you using? – Christopher H Aug 13 at 23:12
  • @powershell_help try adding anything instead of computer.. it will just echo with a blank result.. for example Get-ADComputer -filter * -SearchBase "OU=x,OU=xx,OU=xxx,DC=xxx,DC=com" -Properties * | select cat, dog, rat, company, location – Aravinda Aug 13 at 23:49
  • by the way are you getting any result for select company ? i guess it's empty ! – Aravinda Aug 13 at 23:49
  • 1
    @Powershell_Help: why would I be able to see the company attribute by adding a " | select company" piece into the line when it wasn't originally listed with all the other properties? According to the documentation, Properties only returns a default set of properties, and Company obviously is not one of the default set. docs.microsoft.com/en-us/powershell/module/addsadministration/… – Greg Askew Aug 16 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.