Advertisement
AnatoliyTkachev

Untitled

Sep 13th, 2019
5,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. # Copyright © 2019, Microsoft Corporation. All rights reserved.
  2.  
  3. function T-R
  4. {
  5. [CmdletBinding()]
  6. Param(
  7. [String] $n
  8. )
  9.  
  10. $o = Get-Item -LiteralPath $n -ErrorAction SilentlyContinue
  11. return ($o -ne $null)
  12. }
  13.  
  14. function R-R
  15. {
  16. [CmdletBinding()]
  17. Param(
  18. [String] $l
  19. )
  20.  
  21. $m = T-R $l
  22. if ($m) {
  23. Remove-Item -Path $l -Recurse -ErrorAction SilentlyContinue
  24. }
  25. }
  26.  
  27. function S-D {
  28. R-R "HKLM:\SOFTWARE\Microsoft\Cortana\Testability"
  29. }
  30.  
  31. function K-P {
  32. [CmdletBinding()]
  33. Param(
  34. [String] $g
  35. )
  36.  
  37. $h = Get-Process $g -ErrorAction SilentlyContinue
  38.  
  39. $i = $(get-date).AddSeconds(2)
  40. $k = $(get-date)
  41.  
  42. # While the timeout hasn't been hit
  43. while ((($i - $k) -gt 0) -and $h) {
  44. $k = $(get-date)
  45.  
  46. $h = Get-Process $g -ErrorAction SilentlyContinue
  47. if ($h) {
  48. $h.CloseMainWindow() | Out-Null
  49. Stop-Process -Id $h.Id -Force
  50. }
  51.  
  52. $h = Get-Process $g -ErrorAction SilentlyContinue
  53. }
  54. }
  55.  
  56. function D-FF {
  57. [CmdletBinding()]
  58. Param(
  59. [string[]] $e
  60. )
  61.  
  62. foreach ($f in $e) {
  63. if (Test-Path -Path $f) {
  64. Remove-Item -Recurse -Force $f -ErrorAction SilentlyContinue
  65. }
  66. }
  67. }
  68.  
  69. function D-W {
  70.  
  71. $d = @("$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\AppCache",
  72. "$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\INetCache",
  73. "$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\INetCookies",
  74. "$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\INetHistory",
  75. "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\AppCache",
  76. "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\INetCache",
  77. "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\INetCookies",
  78. "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\INetHistory")
  79.  
  80. D-FF $d
  81. }
  82.  
  83. function R-L {
  84. [CmdletBinding()]
  85. Param(
  86. [String] $c
  87. )
  88.  
  89. K-P $c 2>&1 | out-null
  90. D-W # 2>&1 | out-null
  91. K-P $c 2>&1 | out-null
  92.  
  93. Start-Sleep -s 5
  94. }
  95.  
  96. Write-Output "Verifying that the script is running elevated"
  97. if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
  98. if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
  99. $Cx = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
  100. Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $Cx
  101. Exit
  102. }
  103. }
  104.  
  105.  
  106. $a = "searchui"
  107.  
  108. Write-Output "Resetting Windows Search Box"
  109. S-D 2>&1 | out-null
  110. R-L $a
  111.  
  112. Write-Output "Done..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement