Active Directory modifying IP phone via powershell

Associate
Joined
10 Nov 2007
Posts
809
Location
Southampton
I am writing a script to automate user creation and one of the fields I need to edit is the ipPhone field.

The script will prompt the user to enter a value for the ipPhone and store it as a variable.

I looked at using Set-Aduser but it does not have a property for ipPhone.

Is anyone aware of a way I can add this in to avoid the users opening AD and entering it manually?
 
Associate
OP
Joined
10 Nov 2007
Posts
809
Location
Southampton
Thanks for your reply.Below is the code I am using. I tried doing this but received the error at the bottom. This is not something I can do with a CSV either as it is to be used as a when needed basis and we cannot give the user direct access to the AD console either. they will just be given this script type the first name and last name then the ip phone number in and then the script will update the field.

Code:
$fn = Read-host "Enter first name"
$ln - Read-host "Enter Late Name"
$ipp = Read-Host "Enter IP phone of user. If it does not exist then exit"
$GO = get-aduser -identity "$fn.$ln"
Get-ADUser $GO | Set-ADUser -Add @{ipPhone=$ipp}

Set-ADUser : Invalid type 'System.Management.Automation.PSObject'.
Parameter name: ipPhone
At C:\scripts\Harmoni new users.ps1:145 char:18
+ Get-ADUser $GO | Set-ADUser -Add @{ipPhone=$ipp}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (CN=Jack Neighbo...oni,DC=co,DC=uk:ADUser) [Set-ADUser], ArgumentException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.SetADUser
 
Soldato
Joined
3 Jun 2005
Posts
3,119
Location
The South
I'm extremely rusty on Powershell, so hopefully someone else with better knowledge will come along, but is $GO returning the correct username for the user?
Also i'm assuming the ipPhone value is empty?
 
Associate
OP
Joined
10 Nov 2007
Posts
809
Location
Southampton
I have managed to complete it using the following. Thanks for your help on this :)

Code:
$fn = Read-host "Enter first name"
$ln - Read-host "Enter Late Name"
$ipp = Read-Host "Enter IP phone of user. If it does not exist then exit"
$SETIPPHONE = GET-ADUSER "$FN $LN" -PROPERTIES ipPhone
$SETIPPHONE.ipphone = $ipp
set-aduser -Instance $setipphone
 
Back
Top Bottom