Check if a Contact Exists


For more information on using this script, see the article Adminstratively Managing User Contact Lists by Nick Smith.

 

#Contributed by Nick Smith, Microsoft

#Supported Versions: Office Communications Server 2007 R2

#Get User Information

$User = Get-WmiObject -Query “Select * from MSFT_SIPESUserSetting where PrimaryURI = ‘sip:user@domain.com‘”

$UserInstanceID = $User.InstanceID

 

#Check if contact is already added to user’s contact list

$Contact = (Get-WmiObject -Query “Select * from MSFT_SIPESUserContactData where UserInstanceID = ‘$UserInstanceID'” | Where {$_.SIPURI -like “sip:userToCheck@domain.com})

 

if ($Contact -ne $null) { #The contact is on the user’s contact list

      Write-Host “The contact exists on the user’s contact list”

}

elseif ($Contact -eq $null) { #The contact is not on the user’s contact list

      Write-Host “The contact does not exist on the user’s contact list”

}

Skip to main content