Tuesday, July 8, 2014

PowerShell function to modify Active Directory IP Phone Attributes

I follow many different PowerShell Scripting blogs and discussion groups, today someone said to the group, "I need to Update AD Attribute (IP Phone) for Bulk Users at a time."

Here's what I came up with;

<#
.CREATED BY:
    Matthew A. Kerfoot
.CREATED ON:
    07/08/2014
.SYNOPSIS
   create and set IP Phone number in AD
.DESCRIPTION
   This function will create and set the IP Phone attribute in Active Directory per user specified.
.EXAMPLE
   Set-IPPhone -username mkerfoot -New_IP_Phone_Number 555-555-5555
#>

 function Set-IPPhone { 
                        [CmdletBinding()]
                Param ( [Parameter(Mandatory=$true,
                        ValueFromPipelineByPropertyName=$true,
                        Position=0)]
                        $username,
                        [Parameter(Mandatory=$true,
                        ValueFromPipelineByPropertyName=$true,
                        Position=0)]
                        $New_IP_Phone_Number )

 Begin { import-module activedirectory }

 Process { 
 
            $user = Get-ADUser -identity $username | Foreach-Object { $lookup = "LDAP://" + $_.DistinguishedName;[ADSI]$lookup}

            $user.put("IPPhone","$New_IP_Phone_Number") 
         }

 End { $user.setinfo() }

 } Set-IPPhone

No comments:

Post a Comment