ThinkPaper
asked on
Powershell - update PhysicalDeliveryOfficeName or Physical-Office-Delivery-Location
Experts - Need some help figuring this out.
We have a COTS product which is basically a webpage users can go to update their user info. The problem we have run into is that for Room/Office number, the website updates the "roomNumber" attribute. Unfortunately this is NOT the attribute that Outlook uses to reference Office location. Instead, Outlook seems to reference "physicalDeliveryOfficeNam e".
So since we already had hundreds of folks populate their information, I want to run a powershell command to update the "physicalDeliveryOfficeNam e" to equal "roomNumber".
I am trying to run the commands but it is not working. I assume it is because it is the wrong type?? (As if it's not a one-value string??)
This works to query roomNumber and physicalDeliveryOfficeName
But when I attempt to set the value for physicalDeliveryOfficeName , it fails saying its not a valid:
Here's the errors I get:
(I used this: http://blogs.technet.com/b/ashleymcglone/archive/2012/07/23/how-to-copy-user-attributes-to-another-field-with-powershell.aspx as reference)
We have a COTS product which is basically a webpage users can go to update their user info. The problem we have run into is that for Room/Office number, the website updates the "roomNumber" attribute. Unfortunately this is NOT the attribute that Outlook uses to reference Office location. Instead, Outlook seems to reference "physicalDeliveryOfficeNam
So since we already had hundreds of folks populate their information, I want to run a powershell command to update the "physicalDeliveryOfficeNam
I am trying to run the commands but it is not working. I assume it is because it is the wrong type?? (As if it's not a one-value string??)
This works to query roomNumber and physicalDeliveryOfficeName
get-aduser -LDAPfilter '(roomNumber=*)' -Properties *| select samAccountName, roomNumber, physicalDeliveryOfficeName
But when I attempt to set the value for physicalDeliveryOfficeName
Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber, Physical-Office-Delivery-Location | ForEach-Object {Set-ADObject -Identity $_.DistinguishedName -Replace @{Physical-Office-Delivery-Location=$($_.roomNumber)}}
Here's the errors I get:
PS C:\Windows\system32> get-aduser -identity "testuser" -Properties * | set-aduser "testuser" -physicalDeliveryOfficeName "1400TEST"
Set-ADUser : A parameter cannot be found that matches parameter name 'physicalDeliveryOfficeName'.
At line:1 char:94
+ get-aduser -identity "testuser" -Properties * | set-aduser "testuser" -physicalDeliveryOfficeName <<<< "1400TEST"
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser
PS C:\Windows\system32> get-aduser -identity "testuser" -Properties * | set-aduser "testuser" -physical-Delivery-Office-Location "1400TEST"
Set-ADUser : A parameter cannot be found that matches parameter name 'physical-Delivery-Office-Location'.
At line:1 char:101
+ get-aduser -identity "testuser" -Properties * | set-aduser "testuser" -physical-Delivery-Office-Location <<<< "1400TEST"
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser
(I used this: http://blogs.technet.com/b/ashleymcglone/archive/2012/07/23/how-to-copy-user-attributes-to-another-field-with-powershell.aspx as reference)
physicalDeliveryOfficeName is the LDAP display name of Property Office... So
Set-ADUser -Identity $_.DistinguishedName -Office $_.roomNumber should also work..
Set-ADUser -Identity $_.DistinguishedName -Office $_.roomNumber should also work..
Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber | % {Set-ADUser -Identity $_.DistinguishedName -Office $_.roomNumber}
@Subsun - I thought they were the same, but when I checked the help for Set-ADUser to verify it said that the ldapdisplayname for -Office was "office", so I assumed I remembered incorrectly. Just ran through an actual test and you're right. Stupid documentation....
Yes.. some MS KB's have incorrect information..
I'm actually more tolerant of errors in online documentation than I am for built-in help, but I suppose for PS 3.0 they're all from the same source with the dynamic help.
Only thing I remember is, PS3 has a updatable Help. If you need the online help then you need to use the -online switch.. or use the Update-Help or Save-Help cmdlets to update the local help files..
Get-Help <cmdlet-name> -Online
Get-Help <cmdlet-name> -Online
ASKER
@subsun:
I attempted to run using the "Office" attribute:
and got these errors:
If I try physicaldeliveryofficename , I get this:
?
When I run this I get no errors. But the problem is that the Office is STILL EMPTY. It does not update the field. =( What am I missing? Did it work for you guys?
I attempted to run using the "Office" attribute:
Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber | % {Set-ADUser -Identity $_.DistinguishedName -Office $_.roomNumber}
and got these errors:
Set-ADUser : Cannot convert 'Microsoft.ActiveDirectory.Managemen t.ADProper tyValueCol lection' to the type 'System.String' required by parameter 'Office'. Specified method is n
ot supported.
At line:1 char:118
+ Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber | % {Set-ADUser -Identity $_.DistinguishedName -Office <<<< $_.roomNumber}
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Acti veDirector y.Manageme nt.Command s.SetADUse r
If I try physicaldeliveryofficename
Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber | % {Set-ADUser -Identity $_.DistinguishedName -PhysicalDeliveryOfficeName $_.roomNumber}
Set-ADUser : A parameter cannot be found that matches parameter name 'PhysicalDeliveryOfficeNamI am wondering if it is because roomNumber is a different type vs physicaldeliveryofficenamee'.
At line:1 char:138
+ Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber | % {Set-ADUser -Identity $_.DistinguishedName -PhysicalDeliveryOfficeName <<<< $_.roomNumber}
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Act iveDirecto ry.Managem ent.Comman ds.SetADUs er
When I run this I get no errors. But the problem is that the Office is STILL EMPTY. It does not update the field. =( What am I missing? Did it work for you guys?
Get-ADUser -LDAPFilter '(roomNumber=*)' -Properties roomNumber | ForEach-Object {Set-ADObject -Identity $_.DistinguishedName -Replace @{PhysicalDeliveryOfficeName = $_.roomNumber}}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Subsun & footech, you guys rock! We only are using 1 value so no need to take into account multiple values. This was stumping me for a while. @__@ Thanks!! =)
Open in new window