Deleting the Skype for Business Address Books

Deleting the Skype for Business Address Books automatically.

====
Quite a while ago I wrote a small VBScript that deletes all of the GalContacts (Skype for Business local Address Books) for you. It's handy when testing things such as putting new normalisation rules on your Lync or Skype for Business Servers. Combine it with the ability to zero the download delay using the
GalDownloadInitialDelay registry setting and it just makes your life a little bit easier. Initial article was here:

Automatically Deleting the Lync Address Books

Anyways, a few people now have asked me to update the script from VBScript to PowerShell - because the whole world is going PowerShell (and quite rightly, too!). Anyway, I have updated it, and you can download it here:

DelContacts

So what does the script do? It's quite simple - all it does is scan your own profiler any GalContacts.* files and deletes them. You can then use the Lync/Skype client to download new ones.

It even logs the output of what it's doing.

Anyways, scripts like this, while they may not do an awful lot (but they do make your life slightly easier), are a great way to learn PowerShell. In here you'll see how I've done some logging, called some DOS commands, the whole lot. Sure there'll be other/better ways of achieving the same thing, there always are.

Do you need to change anything in the script?
Line 9 contains the path to the log file you wish to use for the script, so you need to change that to your preferred destination. Mine is usually on the desktop - but you can set it anywhere you have write access to:

# Set LogPath to the place you want the log files to go
$LogPath="c:\DelContacts\DelContacts.TXT"


How do you run the script?
Start PowerShell, go in to the directory you have the script in, and use this command:

.\DelContacts.ps1

Bear in mind you will need to have appropriately set the
set-executionpolicy to allow the script to run.

Log File Output
The log file will tell you what it has done - example output below.

Can I create a desktop shortcut to it?
Yes, absolutely. Create a shortcut pointing to:

Powershell.exe PathToScript\DelContacts.PS1

For example on my Windows 10 desktop, I have a shortcut pointing to:

powershell.exe C:\DelContacts\DelContacts.ps1


===========================================================================
Computername : HUGEPC
User Name : mark_
Temp Dir : C:\Users\mark_\AppData\Local\Temp
Profile Path : C:\Users\mark_
Temp File : C:\Users\mark_\AppData\Local\TempDelContacts.TMP
===========================================================================
Finding files using the command: DIR C:\Users\mark_\GalContacts.* /s /b >C:
\Users\mark_\AppData\Local\TempDelContacts.TMP
Temporary file found...
Deleting files....
Working on : C:\Users\mark_\AppData\Local\Microsoft\Office\15.0\Lync\sip_ma
rk.*******@******.com\GalContacts.db
File deleted.
Working on : C:\Users\mark_\AppData\Local\Microsoft\Office\15.0\Lync\sip_ma
rk.*******@******\GalContacts.db.idx
File deleted.
===========================================================================
Deleting temporary file...
Temp file deleted.
===========================================================================
Process finished.


blog comments powered by Disqus