-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clean_SkypeSIPProfiles.ps1
51 lines (44 loc) · 1.74 KB
/
Clean_SkypeSIPProfiles.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<#
.SYNOPSIS
Skype SIP Cleaner
.DESCRIPTION
Cleans all users on the PC's Skype SIP files. Usually happens when in a domain Skype starts asking for passwords
.NOTES
Version: 1
Author: userVII
Creation Date: 05-01-2019
Last Update: 05-01-2019
#>
$processNames = @(
"Lync", "Outlook"
)
foreach($p in $processNames){
$aliveProcess = Get-Process $p -ErrorAction SilentlyContinue
if ($aliveProcess) {
Write-Host "Stopping $p process" -ForegroundColor Yellow
$aliveProcess.CloseMainWindow() | Out-Null
# If the kill wasn't graceful
Start-Sleep -Seconds 3
if (!$aliveProcess.HasExited) {
$aliveProcess | Stop-Process -Force
}
}else{
Write-Host "$p wasn't running"
}
}
$users = Get-ChildItem -Path "C:\Users"
foreach($user in $users){
Write-Host "Working on $user"
$SIPPattern = "sip_$($user)*"
$SIPPath = Get-ChildItem -Path "C:\Users\$user\AppData\Local\Microsoft\Office\16.0\Lync\" -Filter $SIPPattern -Recurse | Where-Object {$_.PSIsContainer} | Select-Object -ExpandProperty Fullname
if(Test-Path $SIPPath){
Write-Host "Found Skype SIP file"
Remove-Item -Path $SIPPath -Force -Recurse
}
if(Test-Path "C:\Users\$user\AppData\Local\Microsoft\Office\16.0\Lync\Tracing"){
Write-Host "Deleting Tracing files"
Remove-Item "C:\Users\$user\AppData\Local\Microsoft\Office\16.0\Lync\Tracing\*.*" | Where { ! $_.PSIsContainer }
}
}
Write-Host "Any file deletion errors are probably from the skype plugin and Outlook being open. Should be fine to reopen Skype now on the users PC"
$pause = Read-Host -Prompt "Press any button to exit..."