-
Notifications
You must be signed in to change notification settings - Fork 97
/
cleanup.yml
248 lines (231 loc) · 6.58 KB
/
cleanup.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# -*- coding: utf-8 -*-
# Copyright 2017, Dag Wieers <[email protected]>
#
# This playbook cleans up a Windows 10 system. It is intended to be used on
# systems on a regular basis to clean up disk space and remove stale software.
- hosts: computers
gather_facts: no
tasks:
- name: Test system connection
wait_for_connection:
timeout: 20
tags: software
- name: Clean chocolatey/nuget cache
win_file:
path: '{{ item }}'
state: absent
with_items:
- '%UserProfile%\AppData\Local\Temp\chocolatey\'
- '%UserProfile%\AppData\Local\Temp\nuget\'
- '%UserProfile%\AppData\Local\NuGet\Cache\'
tags: cache
- name: Remove unwanted software using Chocolatey
win_chocolatey:
name: '{{ item }}'
state: absent
with_items:
- adblockplusfirefox
- adobeair
# - adobereader-de
# - adobereader
# - adobereader-update
- adobeshockwaveplayer
- autoruns
- avastbrowsercleanup
- avastfreeantivirus
- avgantivirusfree
- avginternetsecurity
- avgpctuneup
- avirafreeantivirus
# - dropbox
- flashplayerplugin
- flashplayeractivex
- freerdp
- libreoffice
- openoffice
- procexp
- quicktime
- windbg
tags:
- chocolatey
- software
- hosts: computerlokaal:extra:technieklokaal:new
strategy: free
tasks:
- name: Remove software
win_shell: |
$changed = $false
$apps = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -like "{{item}}"
}
if ($apps.Count -eq 0) {
Write-Host "No package found named '{{ item }}'"
exit 0
}
ForEach ($app in $apps) {
Write-Host "DEBUG: $app"
Try {
$app.Uninstall()
$changed = $true
Write-Host "Successfully uninstalled app '${$app.Name}"
} Catch {
Write-Host "Error: ${$_.Exception.Messsage}"
exit 2
}
}
if ($changed) {
exit 1
}
exit 0
with_items:
- Adobe AIR
- Adobe Flash Player 10 ActiveX
- Acrobat Reader X
- Lenovo Solution Center
- SDK Debuggers
# Lenovo laptops
- Absolute Reminder
- Alcor Micro Smart Card Reader Driver
- Corel WinDVD
- Google Toolbar for Internet Explorer
- Integrated Camera
#- Intel(R) PROSet/Wireless Driver
#- Intel(R) PROSet/Wireless Software for Bluetooth(R)*
- Intel(R) Smart Connect Technology 4.1 x64
- Intel(R) WiDi
- Inst5676
- Lenovo Auto Scroll Utility
- Lenovo Mobile Broadband Activation
- Lenovo Power Management Driver
- Lenovo QuickCast
- Lenovo QuickControl
- Lenovo User Guide
- Lenovo Welcome
- Message Center Plus
#- Microsoft Visual C++ *
#- Intel® PROSet/Wireless WiFi Software
- Intel(R) SDK for OpenCL*
- Intel(R) USB 3.0*
- Mobile Broadband Drivers
- Nitro Pro 8
- Norton Internet Security
- On Screen Display
- Realtek Card Reader
- Realtek High Definition Audio Driver
- Registry Patch to Enable Maximum Power Saving*
- Stuurprogramma voor Intel® Graphics*
- SugarSync Manager
- Thinkpad UltraNav Driver
- ThinkVantage Access Connections
- ThinkVantage Active Protection System
- ThinkVantage Communications Utility
- ThinkVantage AutoLock
- Thinkpad UltraNav Utility
- Thinkpad UltraNav DriverA
- Thinkpad Modem Adapter
- Validity WBF DDK 5011
- VIPAccess
- Windows Driver Package *
- Windows Live Mesh *
register: this
failed_when: this.rc > 1
changed_when: this.rc == 1
tags:
- windows
- purge
# - name: Disable Windows Features
# win_feature:
# name: '{{ item }}'
# state: absent
# with_items:
# - Hearts
# - Internet-Explorer-Optional-amd64
- hosts: computerlokaal
tasks:
- name: Remove all Appx packages for user leerling
win_shell: |
Get-AppxPackage | Remove-AppxPackage
register: appx
changed_when: "'Deployment operation progress: ' in appx.stderr"
failed_when: no
become: leerling
tags: appx
- name: Remove all Appx packages for user leerling
win_shell: |
Get-AppxPackage -User leerling | Remove-AppxPackage
register: appx
changed_when: "'Deployment operation progress: ' in appx.stderr"
failed_when: no
tags: appx
- hosts: computers
tasks:
- name: Remove all Appx packages for this user
win_shell: |
Get-AppxPackage | Remove-AppxPackage
#Get-AppxPackage -AllUsers | Remove-AppxPackage
register: appx
changed_when: "'Deployment operation progress: ' in appx.stderr"
failed_when: no
tags: appx
- name: Remove all Appx provisioned packages
win_shell: |
Get-AppxProvisionedPackage -Online | Remove-AppxProvisionedPackage -Online
register: appx
# changed_when: "'Deployment operation progress: ' in appx.stderr"
failed_when: no
become: yes
tags: appx
#- hosts: computers
# tasks:
# - win_shell: |
# Get-AppxPackage -AllUsers -Name {{ item }} | Remove-AppxPackage
# #Get-AppxPackage -Name {{ item }} | Remove-AppxPackage
# with_items:
# - 4DF9E0F8.Netflix
# - 9E2F88E3.Twitter
# - '*CandyCrush*'
# - E046963F.LenovoCompanion
# - Microsoft.3DBuilder
# - Microsoft.Advertising.Xaml
# - Microsoft.Appconnector
# - Microsoft.BingFinance
# - Microsoft.BingNews
# - Microsoft.BingSports
# - Microsoft.BingWeather
# - Microsoft.CommsPhone
# - Microsoft.ConnectivityStore
# - Microsoft.DesktopAppInstaller
# - Microsoft.Getstarted
# - Microsoft.Messaging
# - Microsoft.MicrosoftOfficeHub
# - Microsoft.MicrosoftSolitaireCollection
# - Microsoft.Office.OneNote
# - Microsoft.Office.Sway
# - Microsoft.OneConnect
# - Microsoft.People
# - Microsoft.Services.Store.Engagement
# - Microsoft.SkypeApp
# - Microsoft.StorePurchaseApp
# - Microsoft.WindowsAlarms
# - Microsoft.WindowsCamera
# - Microsoft.windowscommunicationsapps
# #- Microsoft.WindowsDVDPlayer
# - Microsoft.WindowsFeedbackHub
# - Microsoft.WindowsMaps
# - Microsoft.WindowsPhone
# - Microsoft.Windows.Photos
# - Microsoft.WindowsStore
# - Microsoft.XboxApp
# - Microsoft.XboxIdentityProvider
# - Microsoft.ZuneMusic
# - Microsoft.ZuneVideo
# - TuneIn.TuneInRadio
# register: appx
# changed_when: "'Deployment operation progress: ' in appx.stderr"
## failed_when: no
# tags:
# - appx
# - windows
# - raw: >
# $e = (New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}')
# $e.Items() | %{$_.Verbs()} | ?{$_.Name.replace('&','') -match 'Unpin from Start'} | %{$_.DoIt()}