Last active
February 8, 2017 12:34
-
-
Save danjpadgett/6ccd7e5e174e97a7a2dce18633cd46da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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