Lync CallerID black list / block list

After some time using Bing I have manged to do this. Thanks to :

http://ucken.blogspot.no/2012/02/re-routing-incoming-calls-to.html 

I wanted the caller that is blocked to get a announcment.

Step 1. Install Microsot Lync Server 2010/2013 SDK.

Step 2. Create a announcement using new-csannouncement.

New-CsAnnouncement -Identity “Applicationserver:server.contoso.com” -Name “NumberBlocked” -TextToSpeechPrompt “Sorry, Your call has been restricted” -Language “en-US” -whatif

Step 3. Create a unassigned number entry in Lync CP. I used +4787654321 as an example. assigning the announcement from step 2

Step 4. Create a BlockedNumbers.txt file on the Lync FE server share. Adding numbers and action ” +4712345678,block”, one on each line.

Step 5. Add the block/reroute script to “C:\Program Files\Microsoft Lync Server 2010\Server\Core”. Called my scripte CallerIDfilter.am (attached file) Remember to edit the file. Replace entries with your unassigned number,fileshare and domain in the manifest part and contact entry.

Step 6. You could run the “compilespl.exe  CallerIDFilter.am” to validate that it does not contain any compilatio errors.

Step 7. Register the CallerIDfilter.am with the lync pool. :

New-CsServerApplication -Identity “registrar:lyncpool.contoso.com/CallerIDFilter” -Uri http://www.contoso.com/CallerIDFilter  -ScriptName “CallerIDFilter.am” -Critical $False -Enabled $True -Priority 2

CallerIDFilter.am (2,22 kb)

Script to delete files older thans x days

This script will delete files older than 10 days.

$Now = Get-Date
$LastWrite = $Now.AddDays(-10)
$Files = get-childitem -Path “C:\folder_with_files_to_delete” |Where {$_.CreationTime -le $LastWrite}
foreach ($File in $Files)
{Remove-Item -Path $File -Force}

Save this script as “c:\scripts\deleteoldfiles.ps1”

In schedule task select program/script to run : “C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe”

and use : -command “c:\scripts\deleteoldfiles.ps1” as argument

Remember you has to set the execution policy to allow this script to run. (set-executionpolicy -executionpolicy remotesigned)

Update:

For PowerShell 1.0 and filter on file Attribute:

# Written by  Atle Vatland @ Cegal AS
# Remember to change path,attribute and fileextension.
# When tested OK – remove  WHATIF from Remove-item and the files will be deleted.
# Schedule a task.
# Save this script as “c:\scripts\filename.ps1”
# In schedule task select program/script to run : “C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe”
# and use : -command “c:\scripts\filename.ps1” as argument
# Remember you has to set the execution policy to allow this script to run. (set-executionpolicy -executionpolicy remotesigned)
 

$Now = Get-Date
$LastWrite = $Now.AddDays(-14)
$Files = get-childitem -Path “E:\filepath\*” -include *.ext |Where {$_.LastWriteTime -le $LastWrite}
$Today= ” ———================== Files deleted ” + $Now + “====================——————–”
$Today | Out-File -filepath c:\scripts\deletedfiles.log -Append
foreach ($File in $Files)

{
$FI=get-item $File
 if($FI.Attribute -notlike “*Archive*”){
  $File | ft -HideTableHeaders | out-file -filepath c:\scripts\deletedfiles.log -Append;remove-item $File -whatif
 }
}