Cogger

VMware_Install.ps1

Jan 4th, 2022 (edited)
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ########################################################################################################################
  2. #=====[ Services ]=====#
  3. ########################################################################################################################
  4. Write-Host('Modifying Services') -Fore Magenta
  5. Write-Host('############################') -Fore Magenta
  6.  
  7. ##  Variables that are called.
  8.     $CDPSvc = 'CDPSvc'
  9.     $sysmain = 'sysmain'
  10.     $WSearch = 'WSearch'
  11.     $DiagTrack = 'DiagTrack'
  12.     $DISS = 'diagnosticshub.standardcollector.service'
  13.     $ARMS = 'AdobeARMservice'
  14.  
  15. ##  Set the startup services to disabled
  16.     Set-Service -Name $CDPSvc -StartupType Disabled
  17.     Set-Service -Name "$sysmain" -StartupType Disabled
  18.     Set-Service -Name "$WSearch" -StartupType Disabled
  19.     Set-Service -Name "$DiagTrack" -StartupType Disabled
  20.     Set-Service -Name "$DISS" -StartupType Disabled
  21.     Set-Service -Name "$ARMS" -StartupType Manual
  22.  
  23. ##  Stop services
  24.     Stop-Service -Name $CDPSvc -Force -Confirm:$false
  25.     Stop-Service -Name "$sysmain" -Force -Confirm:$false
  26.     Stop-Service -Name "$WSearch" -Force -Confirm:$false
  27.     Stop-Service -Name "$DiagTrack" -Force -Confirm:$false
  28.     Stop-Service -Name "$DISS" -Force -Confirm:$false
  29.     Stop-Service -Name "$ARMS" -Force -Confirm:$false
  30.  
  31. ##  Write to the shell what is being done.
  32.     Write-Host('Stopping and Disabling CDPSvc...') -Fore Magenta
  33.     Write-Host('Stopping and Disabling Sysmain...') -Fore Magenta
  34.     Write-Host('Stopping and Disabling WSearch...') -Fore Magenta
  35.     Write-Host('Stopping and Setting AdobeARMservic to Manual...') -Fore Magenta
  36.     Write-Host('Stopping and Disabling DiagTrack...') -Fore Magenta
  37.     Write-Host('Stopping and Disabling diagnosticshub.standardcollector.service..') -Fore Magenta
  38.  
  39. ### Stop Update Services
  40.     Write-Host('Stopping and Starting Update services...') -Fore Magenta
  41.         Stop-Service -Name "wuauserv" -Force -Confirm:$false
  42.         Stop-Service -Name "bits" -Force -Confirm:$false
  43.         Start-Sleep -s 1
  44.  
  45. ### Set Update Services to start automatically
  46.     Set-Service -Name wuauserv -StartupType Automatic
  47.     Set-Service -Name bits -StartupType Automatic
  48.         Start-Sleep -s 1
  49.  
  50. ### Start Update Services
  51.     Start-Service -Name BITS
  52.     Start-Service -Name wuauserv
  53.         Start-Sleep -s 1
  54.  
  55.  
  56. ### RegKey to disable UAC
  57. Write-Host('Disabling UAC...') -Fore DarkGray
  58.     reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
  59.  
  60. ### RegKey to Disable Internet Explorer first time run start requirements.
  61. Write-Host('Disabling Internet Explorer First Time Run...') -Fore DarkGray
  62.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 2 -EA SilentlyContinue
  63.  
  64. ### RegKey to Disable Microsoft Edge first time run start requirements.
  65. Write-Host('Disabling MS Edge First time Run...') -Fore DarkGray
  66.     reg load HKLM\Default_User C:\Users\Default\NTUSER.DAT
  67.     New-Item -Path Registry::"HKLM\SOFTWARE\Policies\Microsoft" -Name MicrosoftEdge -EA SilentlyContinue
  68.     reg load HKLM\Default_User C:\Users\Default\NTUSER.DAT
  69.     New-Item -Path Registry::"HKLM\SOFTWARE\Policies\Microsoft\MicrosoftEdge" -Name Main -EA SilentlyContinue
  70.     reg load HKLM\Default_User C:\Users\Default\NTUSER.DAT
  71.     Set-ItemProperty -Path Registry::HKLM\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main -Name AllowPrelaunch -Value 0 -EA SilentlyContinue
  72.  
  73. ##  Change Registry Vaules and Disable known
  74. Write-Host('Disabling services known to cause issues...') -Fore DarkGray
  75.     Add-Content -Path 'C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl' -Value '' -EA SilentlyContinue
  76.     New-ItemProperty -Path "HKCU:\Control Panel\Desktop"  -Name "AutoEndTasks" -Value 0 -EA SilentlyContinue
  77.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\xboxgip"  -Name "Start" -Value 4 -EA SilentlyContinue
  78.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\XboxGipSvc"  -Name "Start" -Value 4 -EA SilentlyContinue
  79.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\CDPUserSvc"  -Name "Start" -Value 4 -EA SilentlyContinue
  80.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\UnistoreSvc" -Name "Start" -Value 4 -EA SilentlyContinue
  81.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\UserDataSvc" -Name "Start" -Value 4 -EA SilentlyContinue
  82.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\XblGameSave"  -Name "Start" -Value 4 -EA SilentlyContinue
  83.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\XboxNetApiSvc"  -Name "Start" -Value 4 -EA SilentlyContinue
  84.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\XblAuthManager"  -Name "Start" -Value 4 -EA SilentlyContinue
  85.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\PimIndexMaintenanceSvc" -Name "Start" -Value 4 -EA SilentlyContinue
  86.     New-Item -Path "HKLM:\SYSTEM\ControlSet001\Control\WMI" -Name "AutoLogger" -EA SilentlyContinue
  87.     Set-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener"  -Name "Start" -Value 0 -EA SilentlyContinue
  88.     New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\CompatTelRunner.exe" -Name "Debugger" -PropertyType String -Value %windir%\System32\taskkill.exe -EA SilentlyContinue
  89.  
  90. ### Kill Windows Search UI
  91. Write-Host('Killing Windows Search....') -Fore DarkGray
  92.     Stop-Process -Name "SearchUi.exe" -Force -EA SilentlyContinue
  93.     Stop-Process -Name "SearchUi.exe" -Force -EA SilentlyContinue
  94.     Stop-Process -Name "SearchUi.exe" -Force -EA SilentlyContinue
  95.  
  96.  
  97. ### Disable Windows Search
  98. Write-Host('Disabling Windows Search...') -Fore DarkGray
  99.     New-Item -Path Registry::"HKLM\SOFTWARE\Policies\Microsoft\Windows" -Name "Windows Search" -EA SilentlyContinue
  100.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"  -Name "AllowCortana" -Value 0
  101.         If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings")) {
  102.             New-Item -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Force | Out-Null
  103.           }
  104.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -Type DWord -Value 0
  105.         If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization")) {
  106.             New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Force | Out-Null
  107.           }
  108.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 1
  109.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 1
  110.         If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) {
  111.             New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null
  112.           }
  113.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -Type DWord -Value 0
  114.         If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
  115.             New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
  116.             }
  117.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0
  118.    
  119. ### Disable Windows Search Info Box
  120. Write-Host('Disabling Windows Search Informational box to re-enable...') -Fore DarkGray
  121.     New-Item –Path Registry::"HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer" –Name InfoBarsDisabled
  122.     New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\InfoBarsDisabled" -Name "LocationNotIndexed" -PropertyType DWord -Value 1 -EA SilentlyContinue
  123.     New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\InfoBarsDisabled" -Name "ServerMSSNotInstalled" -PropertyType Dword -Value 1 -EA SilentlyContinue
  124.  
  125. ### RegKey to set Automatic Updates to download automatically and allow for their installation.
  126. Write-Host('Setting Up Windows Update...') -Fore Gray
  127.     New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows" -Name "WindowsUpdate"
  128.     New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "AU"
  129.     New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name AUOptions -Value 3
  130.      
  131. ##  This will auto configure the next time that the workstation reboots.
  132. Write-Host('Silently Auto Configuring OneDrive...') -Fore DarkGreen
  133.     New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\OneDrive" -Name "SilentAccountConfig" -PropertyType "DWord" -Value "0x1" -EA SilentlyContinue
  134.  
  135. mkdir C:\temp -EA SilentlyContinue
  136.  
  137. Set-Location -Path C:\temp
  138.  
  139. $URL = 'https://www.mediafire.com/file/xlx5wocvpas19lg/VMware-Horizon-Agent-x86_64-2106-8.3.0-18287218.exe/file'
  140. $DownloadLink2 = (Invoke-WebRequest -Uri $URL -UseBasicParsing).Links | sort-object href -Unique | Select-Object href | Select-String -Pattern 'https://download' -SimpleMatch
  141. $DownloadLink1 = $DownloadLink2 -replace "@{href=" -replace "" ; $Source = $DownloadLink1 -replace "}" -replace ""
  142. $DIR = $(get-location).Path ; $APP = ($Source.Split('/',6) | Select -Index 5) ; $DIRAPP = $DIR + "\" + $APP
  143. Start-BitsTransfer -Source $Source -Destination $DIRAPP
  144.  
  145. C:\temp\VMware-Horizon-Agent-x86_64-2106-8.3.0-18287218.exe /silent /install /norestart
  146.  
Add Comment
Please, Sign In to add comment