Advertisement
Guest User

updates

a guest
Aug 8th, 2020
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. write-host
  2. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. write-host ~~~   Preconf
  4. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. write-host
  6. $ErrorActionPreference = 'SilentlyContinue'
  7.  
  8.  
  9.  
  10. # Get a list of all the VPN subnets per office to set the location of the computer
  11.  
  12. $office1list = Get-Content "\\195.1.1.53\pub\PSScripts\common_data\vpn_subnets\office1.txt"
  13. $office2list = Get-Content "\\195.1.1.53\pub\PSScripts\common_data\vpn_subnets\office2.txt"
  14. $office3list = Get-Content "\\195.1.1.53\pub\PSScripts\common_data\vpn_subnets\Office3.txt"
  15.  
  16. # Set some variables
  17. $cppath="C:\cp"
  18. $bbpath="C:\Program Files\BleachB"
  19. $getoffice="C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
  20. $visio="C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
  21. $firefox="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
  22.  
  23. # Function that kills common running processes which I want out of the way
  24. function Refresh-Environment {
  25. $taskkill_list="explorer*","firefo*","perfmo*","chrome*","iexplore*","*Edge*","mstsc*","Dropb*","snagit*"
  26. $taskkill_list | foreach { Get-Process -Name $_ | Stop-Process -force }
  27. start "explorer.exe"
  28. }
  29.  
  30. # Define if it's a laptop or a desktop.
  31. if ($env:computername -like "*companylt*") {
  32. $dev_type="laptop"
  33. } ELSEIF ( $env:computername -like "*companyws*") {
  34. $dev_type="desktop"
  35. }else {
  36. Write-Host "/!\/!\/!\/!\/!\ Check computername /!\/!\/!\/!\/!\/!\"
  37. $dev_type="laptop"
  38. Write-Host $env:computername $dev_type
  39. pause
  40. }
  41.  
  42. # Set WINS and DNS servers
  43. Get-NetIPAddress | where -Property IPAddress -Like 195.1.* | select -ExpandProperty InterfaceAlias | foreach { netsh interface ip add wins name=$_ addr=195.1.1.1 index=0 }
  44. Get-NetIPAddress | where -Property IPAddress -Like 195.1.* | select -ExpandProperty InterfaceAlias | foreach { Set-DnsClientServerAddress -InterfaceAlias $_ -ServerAddresses 195.1.1.1,9.9.9.9,1.1.1.1 }
  45. Get-NetIPAddress | where -Property IPAddress -Like 18.0.* | select -ExpandProperty InterfaceAlias | foreach { netsh interface ip add wins name=$_ addr=195.1.1.1 index=0 }
  46. Get-NetIPAddress | where -Property IPAddress -Like 18.0.* | select -ExpandProperty InterfaceAlias | foreach { Set-DnsClientServerAddress -InterfaceAlias $_ -ServerAddresses 18.0.0.3,9.9.9.9,1.1.1.1 }
  47.  
  48.  
  49. $ipis = Get-NetIPAddress | where {($_.IpAddress -like '192.*') -and ($_.AddressFamily -eq 'IPv4')} | select -ExpandProperty IPAddress
  50. $ipis_b = Get-NetIPAddress | where {($_.IpAddress -like '10.*') -and ($_.AddressFamily -eq 'IPv4')} | select -ExpandProperty IPAddress
  51.  
  52. # Define WSUS server IP address
  53. if ($office2list | Where-Object {$ipis -match [regex]::escape($_)})
  54. {
  55. Write-Host "office2"
  56. $loc = "office2"
  57. $WSUS_IP = "http://195.1.2.220:8530"
  58. }elseif ($office1list | Where-Object {$ipis -match [regex]::escape($_)})
  59. {
  60. Write-Host "office1"
  61. $loc = "office1"
  62. $WSUS_IP = "http://195.1.1.220:8530"
  63. } elseif ($office3list | Where-Object {$ipis -match [regex]::escape($_)})
  64. {
  65. Write-Host "office3"
  66. $loc = "Office3"
  67. $WSUS_IP = "http://195.1.1.220:8530"
  68. } else {
  69. $loc = "External IP"
  70. }
  71.  
  72. write-host
  73. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. write-host ~~~   Install WSUS, Start WU Services + Check
  75. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. write-host
  77.  
  78. Stop-Service -name "msiserver"
  79. Stop-Service -name "bits"
  80. Stop-Service -name "cryptSvc"
  81. Stop-Service -name "WUAUSERV"
  82.  
  83.  
  84. $wsus_path1 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
  85. $wsus_path2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
  86.  
  87. IF(!(Test-Path $wsus_path1))  {
  88. New-Item -Path $wsus_path1 -Force -OutVariable "tmp"
  89. New-Item -Path $wsus_path2 -Force -OutVariable "tmp"
  90. }
  91. Write-Host "----- Adding Registry keys as computer is not registered in DC"
  92. New-ItemProperty -Path $wsus_path1 -PropertyType DWORD -Force -Name "AcceptTrustedPublisherCerts" -Value "1"  -OutVariable "tmp"
  93. New-ItemProperty -Path $wsus_path1 -PropertyType DWORD -Force -Name "ElevateNonAdmins" -Value "1" -OutVariable "tmp"
  94. New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "TargetGroup" -Value "Workstations" -OutVariable "tmp"
  95. New-ItemProperty -Path $wsus_path1 -PropertyType DWORD -Force -Name "TargetGroupEnabled" -Value "0" -OutVariable "tmp"
  96. New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "WUServer" -Value $WSUS_IP -OutVariable "tmp"
  97. New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "WUStatusServer" -Value $WSUS_IP -OutVariable "tmp"
  98. New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "UpdateServiceUrlAlternate" -Value $WSUS_IP -OutVariable "tmp"
  99. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAutoRebootWithLoggedOnUsers" -Value "1" -OutVariable "tmp"
  100. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "AUOptions" -Value "4" -OutVariable "tmp"
  101. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "AUPowerManagement" -Value "1" -OutVariable "tmp"
  102. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "AutoInstallMinorUpdates" -Value "1" -OutVariable "tmp"
  103. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "DetectionFrequency" -Value "10" -OutVariable "tmp"
  104. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "DetectionFrequencyEnabled" -Value "1" -OutVariable "tmp"
  105. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "IncludeRecommendedUpdates" -Value "1" -OutVariable "tmp"
  106. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAUAsDefaultShutdownOption" -Value "1" -OutVariable "tmp"
  107. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAUShutdownOption" -Value "1" -OutVariable "tmp"
  108. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAutoUpdate" -Value "0" -OutVariable "tmp"
  109. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RebootRelaunchTimeout" -Value "10" -OutVariable "tmp"
  110. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RebootRelaunchTimeoutEnabled" -Value "1" -OutVariable "tmp"
  111. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RescheduleWaitTime" -Value "10" -OutVariable "tmp"
  112. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RescheduleWaitTimeEnabled" -Value "1" -OutVariable "tmp"
  113. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "ScheduledInstallDay" -Value "0" -OutVariable "tmp"
  114. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "ScheduledInstallTime" -Value "3" -OutVariable "tmp"
  115. New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "UseWUServer" -Value "1" -OutVariable "tmp"
  116. Write-Host "----- Results of Registry update"
  117. Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -OutVariable "tmp"
  118. Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -OutVariable "tmp"
  119. write-host $tmp
  120. Start-Service -name "msiserver"
  121. Start-Service -name "bits"
  122. Start-Service -name "cryptSvc"
  123. Set-Service "WUAUSERV" -StartupType Automatic
  124. Start-Service -name "WUAUSERV"
  125. wuauclt /resetauthorization
  126. wuauclt /detectnow
  127. wuauclt /reportnow
  128. start "$env:windir\system32\perfmon.exe" /res
  129. (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
  130. explorer.exe "ms-settings:windowsupdate"
  131.  
  132. Write-Host "------WSUS Config  Script End------"
  133.  
  134. # Create a regfile on desktop that disables WSUS
  135. echo "Windows Registry Editor Version 5.00"> "C:\users\$env:username\desktop\removewsus.reg"
  136. echo "">> "C:\users\$env:username\desktop\removewsus.reg"
  137. echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]">> "C:\users\$env:username\desktop\removewsus.reg"
  138. echo '"UseWUServer"=dword:00000000'>> "C:\users\$env:username\desktop\removewsus.reg"
  139.  
  140. # Run windows' clean manager to create a profile
  141. start-process -Filepath "cleanmgr.exe" -ArgumentList "/sageset:11"
  142.  
  143.  
  144. write-host
  145. write-host ~~~   Map Z
  146. write-host
  147. net use A: /delete
  148. net use B: /delete
  149. net use A: \\195.1.1.53\Pub
  150. net use B: '\\195.1.1.13\p&f_data' /user:domain\username password /persistent:yes
  151.  
  152.  
  153. pause
  154.  
  155.  
  156. write-host
  157. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. write-host ~~~   Personalisation, Disable Telemetry and Pre-Installed Adware
  159. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  160. write-host
  161. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search\"
  162. $Name = "BingSearchEnabled"
  163. $value = "0"
  164. IF(!(Test-Path $registryPath))
  165. {
  166. New-Item -Path $registryPath -Force | Out-Null
  167. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  168. } ELSE {
  169. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  170. }
  171.  
  172. $registryPath = "HKCU:\Software\Policies\Microsoft\Windows\Explorer\"
  173. $Name = "HidePeopleBar"
  174. $value = "1"
  175. IF(!(Test-Path $registryPath))
  176. {
  177. New-Item -Path $registryPath -Force | Out-Null
  178. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  179. } ELSE {
  180. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  181. }
  182.  
  183. $registryPath = "HKCU:\Software\Microsoft\Internet Explorer\MINIE"
  184. $Name = "LinksBandEnabled"
  185. $value = "1"
  186. IF(!(Test-Path $registryPath))
  187. {
  188. New-Item -Path $registryPath -Force | Out-Null
  189. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  190. } ELSE {
  191. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  192. }
  193.  
  194. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search"
  195. $Name = "SearchboxTaskbarMode"
  196. $value = "0"
  197. IF(!(Test-Path $registryPath))
  198. {
  199. New-Item -Path $registryPath -Force | Out-Null
  200. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  201. } ELSE {
  202. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  203. }
  204.  
  205. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
  206. $Name = "ShowTaskViewButton"
  207. $value = "0"
  208. IF(!(Test-Path $registryPath))
  209. {
  210. New-Item -Path $registryPath -Force | Out-Null
  211. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  212. } ELSE {
  213. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  214. }
  215.  
  216. $registryPath = "HKCU:\Software\Microsoft\Internet Explorer\Main"
  217. $Name = "Start Page"
  218. $value = "https://rdswelcomepage.company.co.uk"
  219. IF(!(Test-Path $registryPath))
  220. {
  221. New-Item -Path $registryPath -Force | Out-Null
  222. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
  223. } ELSE {
  224. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
  225. }
  226.  
  227. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
  228. $Name = "TaskbarSmallIcons"
  229. $value = "1"
  230. IF(!(Test-Path $registryPath))
  231. {
  232. New-Item -Path $registryPath -Force | Out-Null
  233. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  234. } ELSE {
  235. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  236. }
  237.  
  238. $registryPath = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer"
  239. $Name = "DisableNotificationCenter"
  240. $value = "1"
  241. IF(!(Test-Path $registryPath))
  242. {
  243. New-Item -Path $registryPath -Force | Out-Null
  244. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  245. } ELSE {
  246. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  247. }
  248.  
  249. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer"
  250. $Name = "EnableAutoTray"
  251. $value = "0"
  252. IF(!(Test-Path $registryPath))
  253. {
  254. New-Item -Path $registryPath -Force | Out-Null
  255. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  256. } ELSE {
  257. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  258. }
  259.  
  260. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\Shell\Bags\1\Desktop"
  261. $Name = "40200225"
  262. $value = "1"
  263. IF(!(Test-Path $registryPath))
  264. {
  265. New-Item -Path $registryPath -Force | Out-Null
  266. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  267. } ELSE {
  268. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  269. }
  270.  
  271. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
  272. $Name = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
  273. $value = "0"
  274. IF(!(Test-Path $registryPath))
  275. {
  276. New-Item -Path $registryPath -Force | Out-Null
  277. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  278. } ELSE {
  279. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  280. }
  281.  
  282. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu"
  283. $Name = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
  284. $value = "1"
  285. IF(!(Test-Path $registryPath))
  286. {
  287. New-Item -Path $registryPath -Force | Out-Null
  288. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  289. } ELSE {
  290. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  291. }
  292.  
  293. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
  294. $Name = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}"
  295. $value = "0"
  296. IF(!(Test-Path $registryPath))
  297. {
  298. New-Item -Path $registryPath -Force | Out-Null
  299. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  300. } ELSE {
  301. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  302. }
  303.  
  304. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu"
  305. $Name = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}"
  306. $value = "1"
  307. IF(!(Test-Path $registryPath))
  308. {
  309. New-Item -Path $registryPath -Force | Out-Null
  310. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  311. } ELSE {
  312. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  313. }
  314.  
  315. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy"
  316. $Name = "LetAppsRunInBackground"
  317. $value = "2"
  318. IF(!(Test-Path $registryPath))
  319. {
  320. New-Item -Path $registryPath -Force | Out-Null
  321. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  322. } ELSE {
  323. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  324. }
  325.  
  326. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
  327. $Name = "MMTaskbarEnabled"
  328. $value = "1"
  329. IF(!(Test-Path $registryPath))
  330. {
  331. New-Item -Path $registryPath -Force | Out-Null
  332. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  333. } ELSE {
  334. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  335. }
  336.  
  337. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
  338. $Name = "TaskbarGlomLevel"
  339. $value = "1"
  340. IF(!(Test-Path $registryPath))
  341. {
  342. New-Item -Path $registryPath -Force | Out-Null
  343. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  344. } ELSE {
  345. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  346. }
  347.  
  348. $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
  349. $Name = "MMTaskbarGlomLevel"
  350. $value = "1"
  351. IF(!(Test-Path $registryPath))
  352. {
  353. New-Item -Path $registryPath -Force | Out-Null
  354. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  355. } ELSE {
  356. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  357. }
  358.  
  359. $registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
  360. $Name = "EnableLUA"
  361. $value = "0"
  362. IF(!(Test-Path $registryPath))
  363. {
  364. New-Item -Path $registryPath -Force | Out-Null
  365. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  366. } ELSE {
  367. New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
  368. }
  369.  
  370. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  371. $Name = "FeatureManagementEnabled", "OemPreInstalledAppsEnabled", "RotatingLockScreenEnabled", "RotatingLockScreenOverlayEnabled", "SilentInstalledAppsEnabled", "SystemPaneSuggestionsEnabled", "PreInstalledAppsEnabled", "SoftLandingEnabled", "SubscribedContentEnabled", "PreInstalledAppsEverEnabled", "ContentDeliveryAllowed"
  372. $value = "0", "0", "1", "1", "0", "0", "0", "0", "1", "1", "1"
  373. IF(!(Test-Path $registryPath))
  374. {
  375. New-Item -Path $registryPath -Force | Out-Null
  376. }
  377. $i=0
  378. foreach ($entry in $Name) {
  379. New-ItemProperty -Path $registryPath -Name $entry -Value $value[$i] -PropertyType DWORD -Force | Out-Null
  380. $i++
  381. }
  382.  
  383. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization"
  384. $Name = "DODownloadMode"
  385. $value = "1"
  386. IF(!(Test-Path $registryPath))
  387. {
  388. New-Item -Path $registryPath -Force | Out-Null
  389. }
  390. foreach ($entry in $Name) {
  391. New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType DWORD -Force | Out-Null
  392. }
  393.  
  394. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10001"
  395. $Name = "*"
  396. $value = "1"
  397. IF(!(Test-Path $registryPath))
  398. {
  399. New-Item -Path $registryPath -Force | Out-Null
  400. }
  401. foreach ($entry in $Name) {
  402. New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType DWORD -Force | Out-Null
  403. }
  404.  
  405. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10001"
  406. $Name = "*"
  407. $value = "195.1.1.13"
  408. IF(!(Test-Path $registryPath))
  409. {
  410. New-Item -Path $registryPath -Force | Out-Null
  411. }
  412. foreach ($entry in $Name) {
  413. New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType String -Force | Out-Null
  414. }
  415.  
  416. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10002"
  417. $Name = "*"
  418. $value = "1"
  419. IF(!(Test-Path $registryPath))
  420. {
  421. New-Item -Path $registryPath -Force | Out-Null
  422. }
  423. foreach ($entry in $Name) {
  424. New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType DWORD -Force | Out-Null
  425. }
  426.  
  427. $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10002"
  428. $Name = "*"
  429. $value = "195.1.1.167"
  430. IF(!(Test-Path $registryPath))
  431. {
  432. New-Item -Path $registryPath -Force | Out-Null
  433. }
  434. foreach ($entry in $Name) {
  435. New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType String -Force | Out-Null
  436. }
  437. write-host Done.
  438.  
  439. write-host
  440. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  441. write-host ~~~   Unistalling Oracle Java
  442. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  443. write-host
  444. Write-Host "Getting Java GUIDs"
  445. $javaGUID = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like 'Java 8*'} | select -ExpandProperty IdentifyingNumber
  446. Write-Host "Found : $javaGUID"
  447. foreach ($guid in $JavaGUID) { write-host "Uninstalling Java with ID $guid"; start-process -filepath msiexec -argumentlist "/x $guid /qn" -wait}
  448. Echo "Done."
  449.  
  450.  
  451. write-host
  452. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  453. write-host ~~~   Forcing en-GB Only
  454. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  455. write-host
  456. Set-WinUserLanguageList -Force 'en-GB'
  457.  
  458.  
  459. write-host
  460. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  461. write-host ~~~   Creating Ultimate Power mode
  462. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  463. write-host
  464. powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61
  465. $powerPlan = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerPlan -Filter "ElementName = 'Ultimate Performance'"
  466. $powerPlan.Activate()
  467. powercfg.exe /h off
  468. powercfg -change -monitor-timeout-ac 20
  469. powercfg -change -standby-timeout-ac 20
  470. powercfg -change -hibernate-timeout-ac 20
  471.  
  472. write-host
  473. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  474. write-host ~~~   Disabling Scheduled Defrag
  475. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  476. write-host
  477. If ((Get-ScheduledTask -TaskName 'ScheduledDefrag').State -eq 'Ready')
  478. {
  479.     Disable-ScheduledTask -TaskName 'ScheduledDefrag' -TaskPath '\Microsoft\Windows\Defrag'
  480. }
  481. Get-ScheduledTask -TaskName 'ScheduledDefrag'
  482.  
  483. write-host
  484. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  485. write-host ~~~   Enabling Windows Feature: .Net3
  486. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  487. write-host
  488.  
  489. DISM.EXE /Online /Add-Capability /CapabilityName:NetFx3~~~~
  490. Add-WindowsCapability -Online -Name NetFx3~~~~
  491.  
  492. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  493. write-host ~~~ Get remote files
  494. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  495.  
  496. if ($dev_type -eq "laptop") {
  497. $zcp="A:\cp_laptops" } ELSE {
  498. $zcp="A:\cp"
  499. }
  500.  
  501. IF((Test-Path $cppath))
  502. {
  503. remove-item -recurse -force -Path $cppath
  504. } ELSE {
  505. mkdir "$cppath"
  506. }
  507.  
  508. xcopy /E /Y /I $zcp "C:\cp"
  509.  
  510.  
  511. # Set wallpaper
  512. mkdir "C:\wallpaper"
  513. xcopy /E /Y /I "A:\deploy\Wallpaper" "C:\wallpaper"
  514.  
  515. & "C:\wallpaper\binary\WallpaperChanger.exe" "C:\wallpaper\image\company.png" 1
  516.  
  517. write-host
  518. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  519. write-host ~~~   Uninstall OneDrive
  520. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  521. write-host
  522. write-host Closing OneDrive process.
  523. write-host
  524. taskkill /f /im OneDrive.exe
  525. Start-Sleep -s 5
  526. write-host Uninstalling OneDrive.
  527. write-host
  528. IF((Test-Path $x64))
  529. {
  530. start-process -filepath "C:\windows\SysWOW64\OneDriveSetup.exe" -ArgumentList '/uninstall'
  531.  
  532. } else {
  533. start-process -filepath "C:\windows\System32\OneDriveSetup.exe" -ArgumentList '/uninstall'
  534. }
  535. Start-Sleep -s 5
  536. write-host Removing OneDrive leftovers.
  537. write-host
  538. remove-item -recurse -force -Path "$env:userprofile\OneDrive"
  539. remove-item -recurse -force -Path "C:\OneDriveTemp"
  540. remove-item -recurse -force -Path "$env:localappdata\Microsoft\OneDrive"
  541. remove-item -recurse -force -Path "C:\programdata\Microsoft OneDrive"
  542. write-host Removing OneDrive from the Explorer Side Panel.
  543. write-host
  544. REG DELETE "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
  545. REG DELETE "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
  546.  
  547. write-host
  548. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  549. write-host ~~~   Uninstall GetOffice
  550. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  551. write-host
  552. IF((Test-Path $getoffice)) {
  553. Start-Process -FilePath "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" -ArgumentList "scenario=install scenariosubtype=ARP sourcetype=None productstowrite-hostove=O365ProPlusRetail.16_en-us_x-none culture=en-us version.16=16.0"
  554. Start-Process -FilePath "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" -ArgumentList "scenario=install scenariosubtype=ARP sourcetype=None productstoremove=O365ProPlusRetail.16_en-us_x-none culture=en-us version.16=16.0"
  555. Start-Process -FilePath "C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe" -ArgumentList "scenario=install scenariosubtype=ARP sourcetype=None productstoremove=VisioProRetail.16_en-us_x-none culture=en-us version.16=16.0"
  556. } ELSE {
  557. write-host GetOffice not found
  558. write-host
  559. }
  560.  
  561. write-host
  562. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  563. write-host ~~~   De-Bloat
  564. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  565. write-host
  566. taskkill /f /im explorer.exe
  567. write-host Lenovo Apps
  568. Get-AppxPackage *lenov* | Remove-AppxPackage
  569. write-host Dell Apps
  570. Get-AppxPackage *dell* | Remove-AppxPackage
  571. write-host Disney
  572. Get-AppxPackage *disn* | Remove-AppxPackage
  573. write-host Bubble Witch
  574. Get-AppxPackage *bubbl* | Remove-AppxPackage
  575. write-host March of Empires
  576. Get-AppxPackage *march* | Remove-AppxPackage
  577. write-host McAfee
  578. Get-AppxPackage *mcaf* | Remove-AppxPackage
  579. write-host 3D Builder
  580. Get-AppxPackage *3dbuilder* | Remove-AppxPackage
  581. write-host Camera
  582. Get-AppxPackage *windowscamera* | Remove-AppxPackage
  583. write-host GetSkype
  584. Get-AppxPackage *skype* | Remove-AppxPackage
  585. write-host Spotify
  586. Get-AppxPackage *spotif* | Remove-AppxPackage
  587. write-host Cyberlink
  588. Get-AppxPackage *cyberl* | Remove-AppxPackage
  589. write-host GetStarted
  590. Get-AppxPackage *getstarted* | Remove-AppxPackage
  591. write-host Zune
  592. Get-AppxPackage *zunemusic* | Remove-AppxPackage
  593. write-host Maps
  594. Get-AppxPackage *windowsmaps* | Remove-AppxPackage
  595. write-host Money
  596. Get-AppxPackage *bingfinance* | Remove-AppxPackage
  597. write-host OneNote
  598. Get-AppxPackage *onenote* | Remove-AppxPackage
  599. write-host News
  600. Get-AppxPackage *bingnews* | Remove-AppxPackage
  601. write-host Sports
  602. Get-AppxPackage *bingsports* | Remove-AppxPackage
  603. write-host Sketchbook
  604. Get-AppxPackage *sketc* | Remove-AppxPackage
  605. write-host Weather
  606. Get-AppxPackage *bingweather* | Remove-AppxPackage
  607. write-host xboxapp
  608. Get-AppxPackage *xboxapp* | Remove-AppxPackage
  609. write-host Twitter
  610. Get-AppxPackage *twitter* | Remove-AppxPackage
  611. write-host Minecraft
  612. Get-AppxPackage *minec* | Remove-AppxPackage
  613. write-host Candy Crush
  614. Get-AppxPackage *candy* | Remove-AppxPackage
  615. write-host Plex
  616. Get-AppxPackage *plex* | Remove-AppxPackage
  617. write-host Keeper Security
  618. Get-AppxPackage *keep* | Remove-AppxPackage
  619. write-host Feedback hub
  620. Get-AppxPackage *feed* | Remove-AppxPackage
  621. write-host Films and TV
  622. Get-AppxPackage *film* | Remove-AppxPackage
  623. write-host Messaging
  624. Get-AppxPackage *messaging* | Remove-AppxPackage
  625. write-host Paid wifi and mobile
  626. Get-AppxPackage *paid* | Remove-AppxPackage
  627. write-host Xbox Apps
  628. Get-AppxPackage *xbox* | Remove-AppxPackage
  629. write-host Netflix
  630. Get-AppxPackage *netfli* | Remove-AppxPackage
  631. write-host Skype
  632. Get-AppxPackage *skype* | Remove-AppxPackage
  633. write-host Dolby Sound
  634. Get-AppxPackage *dolby* | Remove-AppxPackage
  635. write-host Fitbit Coach
  636. Get-AppxPackage *fitbit* | Remove-AppxPackage
  637. write-host Phototastic
  638. Get-AppxPackage *photota* | Remove-AppxPackage
  639. write-host Cookin Fever
  640. Get-AppxPackage *fever* | Remove-AppxPackage
  641. write-host Skype-Online
  642. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*skype*"} | remove-appxprovisionedpackage -online
  643. write-host Sketch
  644. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*sketch*"} | remove-appxprovisionedpackage -online
  645. write-host People
  646. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*people*"} | remove-appxprovisionedpackage -online
  647. write-host Print3D
  648. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*print3d*"} | remove-appxprovisionedpackage -online
  649. write-host Office-Online
  650. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*office*"} | remove-appxprovisionedpackage -online
  651. write-host MixedReality
  652. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*mixedreality*"} | remove-appxprovisionedpackage -online
  653. write-host 3DViewer
  654. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*3dviewer*"} | remove-appxprovisionedpackage -online
  655. write-host Messaging
  656. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*messaging*"} | remove-appxprovisionedpackage -online
  657. write-host Bing
  658. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*bing*"} | remove-appxprovisionedpackage -online
  659. write-host Zune
  660. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*zune*"} | remove-appxprovisionedpackage -online
  661. write-host Phone
  662. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*phone*"} | remove-appxprovisionedpackage -online
  663. write-host Maps
  664. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*maps*"} | remove-appxprovisionedpackage -online
  665. write-host Camera
  666. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*camera*"} | remove-appxprovisionedpackage -online
  667. write-host Alarm
  668. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*alarm*"} | remove-appxprovisionedpackage -online
  669. write-host Wallet
  670. Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*wallet*"} | remove-appxprovisionedpackage -online
  671. write-host Farm*
  672. Get-AppxPackage *farm* | Remove-AppxPackage
  673. write-host Cookin Fever
  674. Get-AppxPackage *fever* | Remove-AppxPackage
  675. start explorer.exe
  676.  
  677. write-host
  678. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  679. write-host ~~~   Firewall Config
  680. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  681. write-host
  682. if ($dev_type -eq "desktop") {
  683. $fw="off"
  684. } elseif ($dev_type -eq "laptop") {
  685. $fw="on"
  686. }
  687. netsh advfirewall set allprofiles state $fw
  688.  
  689. write-host
  690. write-host ~~~   Install Chocolatey - SetPoint - Chrome -  Acrobat Reader - Air - Silverlight - 7Zip - WinRar - Notepad++ - Flash - Firefox ESR - Zoom
  691. write-host
  692.  
  693. Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  694. choco upgrade setpoint googlechrome adobereader adobeair 7zip winrar notepadplusplus flashplayerppapi firefoxesr zoom -y
  695.  
  696. write-host
  697. write-host ~~~ Remove addons from Chrome
  698. write-host
  699. cls
  700.  
  701. if ($dev_type -eq "laptop") {
  702. choco upgrade antivirusfreeantivirus -y
  703. $chrome_cleanup="", "ghbmnnjooekpmoecnnnilnnbdlolhkhi", "bkiaicqvmhfslxrmjdgzobufxqnmcvyk", "bkiaicqvmhfslxrmjdgzobufxqnmcvyk", "bkiaicqvmhfslxrmjdgzobufxqnmcvyk"
  704. $chrome_cleanup | foreach { remove-item -Path "$env:localappdata\Google\Chrome\User Data\Default\Extensions\$_" -force -Recurse }
  705. }
  706.  
  707. write-host
  708. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  709. write-host ~~~   Installing BleachBit
  710. write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711. write-host
  712. IF((Test-Path -Path "$bbpath")) {
  713. remove-item -recurse -force -Path "$bbpath"
  714. remove-item -recurse -force -Path "$bbpath"
  715. } ELSE {
  716. write-host clean install
  717. }
  718. mkdir "$bbpath"
  719. xcopy /E /Y /I "A:\deploy\bb" "$bbpath"
  720. & "C:\Program Files\WinRAR\WinRAR.exe" x -o+ "$bbpath\BleachB.rar" "$bbpath"
  721. start-sleep -s 10
  722. remove-item -recurse -force -Path "$bbpath\BleachB.rar"
  723.  
  724. write-host
  725. write-host ~~~   Run Bleach Bit
  726. write-host
  727. Start-Process -Wait -FilePath "C:\Program Files\BleachB\bleachbit.exe" -ArgumentList "-c --preset"
  728. Refresh-Environment
  729.  
  730. write-host
  731. write-host ~~~  Device specific configs
  732. write-host
  733.  
  734. if ($dev_type -eq "desktop") {
  735. write-host ~~~  Writing Hosts File
  736. Add-Content C:\windows\system32\drivers\etc\hosts "195.1.1.190 remote.company.co.uk"
  737. #Telegraf
  738. $archive="telegraf-desktop.rar"
  739. $telegraf_path="C:\Program Files\telegraf"
  740. if (Test-Path $telegraf_path) {
  741. C:\"Program Files"\Telegraf\telegraf.exe --service uninstall
  742. Stop-Service Telegraf
  743. $service = Get-WmiObject -Class Win32_Service -Filter "Name='Telegraf'"
  744. $service.delete()
  745. Remove-Item -Path $telegraf_path -Force -Recurse
  746. }
  747. mkdir "$telegraf_path"
  748. if (!(Test-Path "C:\Program Files\7-Zip\7z.exe")) {
  749. xcopy /E /Y /I "A:\Deploy\7z" "$telegraf_path"
  750. start-process -Wait -FilePath "$telegraf_path\7z-Installer.exe" -ArgumentList "/S"
  751. }
  752. Copy-Item -Path "A:\deploy\telegraf-agent\$archive" -Destination "$telegraf_path\telegraf.rar" -Force
  753. cd "$telegraf_path"
  754. start-process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList 'e "C:\Program Files\telegraf\telegraf.rar"'
  755. start-sleep -s 4
  756. remove-item -recurse -force -Path "$telegraf_path\telegraf.rar"
  757. C:\"Program Files"\Telegraf\telegraf.exe --service install
  758. Get-Service telegraf* | Start-Service
  759. sc.exe config telegraf start=delayed-auto
  760.  
  761. } elseif ($dev_type -eq "laptop") {
  762. Remove-Item -Path HKLM:\SOFTWARE\Policies\Lenovo\ -Force -Recurse
  763. write-host ~~~  Update/Login - VPNclient
  764. iwr -uri "https://static.VPNclient.com/apps/windows/VPNclient.exe" -outfile "C:\cp\vpn.exe"
  765. start-process -wait "C:\cp\vpn.exe" -ArgumentList "/S"
  766. choco upgrade antivirus
  767.  
  768. $wifis=(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | out-string
  769. $wifis_rec=$wifis
  770. Write-Host $wifis
  771. Function Remove-WIFIProfile($SSID)
  772. {
  773. (NETSH WLAN DELETE PROFILE NAME=$SSID)
  774. }
  775. $SSIDList=(NETSH WLAN SHOW PROFILE) | Select-String 'All User Profile'
  776. $wifis=$SSIDList | Foreach { [pscustomobject]@{SSID=$_.line.substring(27) }}
  777. $wifis
  778. $wifis | foreach { $tmp=$_.ssid
  779.     if ($tmp -notlike "*company*") {
  780.         Remove-WIFIProfile -ssid  $tmp
  781.     }
  782. }
  783. $wifis
  784. pause
  785. }
  786.  
  787.  
  788. write-host
  789. write-host ~~~   Setup portlocker
  790. write-host
  791.  
  792. $portlocker_path="C:\program files\portlocker"
  793. IF(!(Test-Path "$portlocker_path"))
  794. {
  795. mkdir "C:\program files\portlocker"
  796. xcopy /E /Y /I "C:\cp\portlocker" "C:\program files\portlocker"
  797. start-process -wait "C:\program files\portlocker\portlocker.exe"
  798. } ELSE {
  799. write-host portlocker is already installed
  800. start-process -wait "C:\program files\portlocker\portlocker.exe"
  801. }
  802.  
  803.  
  804. cls
  805.  
  806.  
  807. write-host
  808. write-host ~~~   Clean up Desktop, downloads
  809. write-host
  810.  
  811. mkdir "C:\update_backups\desktop"
  812. mkdir "C:\update_backups\downloads"
  813. xcopy /E /Y /I "C:\Users\$env:username\Desktop" "C:\update_backups\desktop"
  814. remove-item -recurse -force -Path "C:\Users\$env:username\Desktop"
  815. mkdir "C:\Users\$env:username\Desktop"
  816. xcopy /E /Y /I "C:\Users\Public\Desktop" "C:\update_backups\desktop"
  817. remove-item -recurse -force -Path "C:\Users\Public\Desktop"
  818. remove-item -recurse -force -Path "C:\Users\Public\Desktop"
  819. mkdir "C:\Users\Public\Desktop"
  820. xcopy /E /Y /I "C:\Users\$env:username\Downloads" "C:\update_backups\downloads"
  821. remove-item -recurse -force -Path "C:\Users\$env:username\Downloads"
  822. remove-item -recurse -force -Path "C:\Users\$env:username\Downloads"
  823. mkdir "C:\Users\$env:username\Downloads"
  824. Move-Item "C:\cp\media\company.ico" -Destination "C:\windows\company.ico" -Force
  825.  
  826. if ($dev_type -eq "desktop") {
  827. $shortcuts="B:\it\desktop_shortcuts"
  828. } elseif ($dev_type -eq "laptop") {
  829. $shortcuts="B:\it\laptop_shortcuts"
  830. }
  831. xcopy /E /Y /I $shortcuts "C:\Users\$env:username\Desktop"
  832.  
  833. remove-item -recurse -force -Path "C:\update_backups\desktop\Winr*.lnk"
  834. remove-item -recurse -force -Path "C:\update_backups\desktop\Mozi*.lnk"
  835. remove-item -recurse -force -Path "C:\update_backups\desktop\Goog*.lnk"
  836. remove-item -recurse -force -Path "C:\update_backups\desktop\Inter*.lnk"
  837. remove-item -recurse -force -Path "C:\update_backups\desktop\Acro*.lnk"
  838. remove-item -recurse -force -Path "C:\update_backups\desktop\Note*.lnk"
  839. remove-item -recurse -force -Path "C:\update_backups\desktop\CCl*.lnk"
  840. remove-item -recurse -force -Path "C:\update_backups\desktop\Phone*.lnk"
  841. remove-item -recurse -force -Path "C:\update_backups\desktop\Passwordm*.lnk"
  842. remove-item -recurse -force -Path "C:\update_backups\desktop\Snip*.lnk"
  843. remove-item -recurse -force -Path "C:\update_backups\desktop\Firef*.lnk"
  844. remove-item -recurse -force -Path "C:\update_backups\desktop\scansna*.lnk"
  845. remove-item -recurse -force -Path "C:\update_backups\desktop\Deskt*.lnk"
  846. remove-item -recurse -force -Path "C:\update_backups\desktop\VPNclient*.lnk"
  847. remove-item -recurse -force -Path "C:\update_backups\desktop\antivirus*.lnk"
  848. remove-item -recurse -force -Path "C:\update_backups\desktop\Firefox*.lnk"
  849. remove-item -recurse -force -Path "C:\update_backups\desktop\Media*.lnk"
  850. remove-item -recurse -force -Path "C:\update_backups\desktop\Scan*.lnk"
  851. remove-item -recurse -force -Path "C:\update_backups\desktop\*Edge*"
  852. remove-item -recurse -force -Path "C:\update_backups\desktop\Zoom*"
  853. remove-item -recurse -force -Path "C:\update_backups\desktop\removewsus.reg"
  854. remove-item -recurse -force -Path $cppath
  855.  
  856. # Write Log
  857. $timestamp = Get-Date -Format "dddd_MM_dd_yyyy_HH_mm"
  858. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "------------------------------"
  859. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Date Executed"
  860. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $timestamp
  861. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
  862. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Determined location"
  863. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $loc
  864. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
  865. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Computer name"
  866. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $env:Computername
  867. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
  868. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "IPs"
  869. $theip="$ipis" + "$ipis_b"
  870. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $theip
  871. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
  872. $os_Version=[environment]::OSVersion.Version
  873. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "OS Version"
  874. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $os_Version
  875. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
  876.  
  877. if ($dev_type -eq "laptop") {
  878. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Saved WiFi Networks"
  879. $wifis=(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize | out-string
  880. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $wifis_rec
  881. Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
  882. }
  883.  
  884. # Cleanup
  885. net stop WUAUSERV
  886. remove-item -recurse -force -Path "C:\Windows\SoftwareDistribution"
  887. net use /delete B:
  888. net use /delete A:
  889.  
  890. Write-Host "Dism Cleanup"
  891. Dism.exe /online /cleanup-image /startcomponentcleanup
  892.  
  893. start-process -Filepath "cleanmgr.exe" -ArgumentList "/sagerun:11" -wait
  894.  
  895. Start-Process -Wait -FilePath "C:\Program Files\BleachB\bleachbit.exe" -ArgumentList "-c --preset"
  896.  
  897. net start WUAUSERV
  898.  
  899. start-process -FilePath 'C:\Program Files\internet explorer\iexplore.exe'
  900. pause
  901. start-process -FilePath 'shutdown.exe' -ArgumentList '-r -t 5'
  902. remove-item -force -Path 'C:\*.bat'
  903. remove-item -force -Path 'C:\*.ps1'
  904.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement