Skip to content

Instantly share code, notes, and snippets.

@danjpadgett
Last active February 8, 2017 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danjpadgett/6ccd7e5e174e97a7a2dce18633cd46da to your computer and use it in GitHub Desktop.
Save danjpadgett/6ccd7e5e174e97a7a2dce18633cd46da to your computer and use it in GitHub Desktop.
<#
.SYNOPSIS
Sets UPN to ProxyAddresses AD field for SIP entry
.DESCRIPTION
Script will search through active directory and set all users with NO SIP address to have a SIP matching the users UPN
.PARAMETER $OU
Enter full distinguised name of OU you wish to limit search to
.NOTES
Version: 1.0
Author: dpadgett
Creation Date: 07/02/17
Purpose/Change: Initial script development
.EXAMPLE
Set-SIP.ps1 -OU "OU=Development,OU=Users,DC=company,DC=Group"
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[ValidateScript({Get-ADOrganizationalUnit $_})]
[string]$OU
)
$results = Get-ADUser -Filter * -Properties DisplayName, SamAccountName , UserPrincipalName , proxyaddresses -SearchBase $OU |
Select DisplayName , SamAccountName , UserPrincipalName , @{Name='SIPproxyaddresses';Expression={($_.proxyaddresses | Select-String -Pattern "SIP:")}} |
Where-Object {$_.SIPproxyaddresses -eq $null}
ForEach($user in $results)
{
$samAccount = $user.SamAccountName
$SIP = "SIP:$($user.UserPrincipalName)"
Write-Host "Setting $samAccount - SIP; $sip "
Set-ADUser -Identity $samAccount -Add @{proxyAddresses=$SIP}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment