Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Preconf
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- $ErrorActionPreference = 'SilentlyContinue'
- # Get a list of all the VPN subnets per office to set the location of the computer
- $office1list = Get-Content "\\195.1.1.53\pub\PSScripts\common_data\vpn_subnets\office1.txt"
- $office2list = Get-Content "\\195.1.1.53\pub\PSScripts\common_data\vpn_subnets\office2.txt"
- $office3list = Get-Content "\\195.1.1.53\pub\PSScripts\common_data\vpn_subnets\Office3.txt"
- # Set some variables
- $cppath="C:\cp"
- $bbpath="C:\Program Files\BleachB"
- $getoffice="C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
- $visio="C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeClickToRun.exe"
- $firefox="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
- # Function that kills common running processes which I want out of the way
- function Refresh-Environment {
- $taskkill_list="explorer*","firefo*","perfmo*","chrome*","iexplore*","*Edge*","mstsc*","Dropb*","snagit*"
- $taskkill_list | foreach { Get-Process -Name $_ | Stop-Process -force }
- start "explorer.exe"
- }
- # Define if it's a laptop or a desktop.
- if ($env:computername -like "*companylt*") {
- $dev_type="laptop"
- } ELSEIF ( $env:computername -like "*companyws*") {
- $dev_type="desktop"
- }else {
- Write-Host "/!\/!\/!\/!\/!\ Check computername /!\/!\/!\/!\/!\/!\"
- $dev_type="laptop"
- Write-Host $env:computername $dev_type
- pause
- }
- # Set WINS and DNS servers
- 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 }
- 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 }
- 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 }
- 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 }
- $ipis = Get-NetIPAddress | where {($_.IpAddress -like '192.*') -and ($_.AddressFamily -eq 'IPv4')} | select -ExpandProperty IPAddress
- $ipis_b = Get-NetIPAddress | where {($_.IpAddress -like '10.*') -and ($_.AddressFamily -eq 'IPv4')} | select -ExpandProperty IPAddress
- # Define WSUS server IP address
- if ($office2list | Where-Object {$ipis -match [regex]::escape($_)})
- {
- Write-Host "office2"
- $loc = "office2"
- $WSUS_IP = "http://195.1.2.220:8530"
- }elseif ($office1list | Where-Object {$ipis -match [regex]::escape($_)})
- {
- Write-Host "office1"
- $loc = "office1"
- $WSUS_IP = "http://195.1.1.220:8530"
- } elseif ($office3list | Where-Object {$ipis -match [regex]::escape($_)})
- {
- Write-Host "office3"
- $loc = "Office3"
- $WSUS_IP = "http://195.1.1.220:8530"
- } else {
- $loc = "External IP"
- }
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Install WSUS, Start WU Services + Check
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- Stop-Service -name "msiserver"
- Stop-Service -name "bits"
- Stop-Service -name "cryptSvc"
- Stop-Service -name "WUAUSERV"
- $wsus_path1 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
- $wsus_path2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
- IF(!(Test-Path $wsus_path1)) {
- New-Item -Path $wsus_path1 -Force -OutVariable "tmp"
- New-Item -Path $wsus_path2 -Force -OutVariable "tmp"
- }
- Write-Host "----- Adding Registry keys as computer is not registered in DC"
- New-ItemProperty -Path $wsus_path1 -PropertyType DWORD -Force -Name "AcceptTrustedPublisherCerts" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path1 -PropertyType DWORD -Force -Name "ElevateNonAdmins" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "TargetGroup" -Value "Workstations" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path1 -PropertyType DWORD -Force -Name "TargetGroupEnabled" -Value "0" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "WUServer" -Value $WSUS_IP -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "WUStatusServer" -Value $WSUS_IP -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path1 -PropertyType String -Force -Name "UpdateServiceUrlAlternate" -Value $WSUS_IP -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAutoRebootWithLoggedOnUsers" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "AUOptions" -Value "4" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "AUPowerManagement" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "AutoInstallMinorUpdates" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "DetectionFrequency" -Value "10" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "DetectionFrequencyEnabled" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "IncludeRecommendedUpdates" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAUAsDefaultShutdownOption" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAUShutdownOption" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "NoAutoUpdate" -Value "0" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RebootRelaunchTimeout" -Value "10" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RebootRelaunchTimeoutEnabled" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RescheduleWaitTime" -Value "10" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "RescheduleWaitTimeEnabled" -Value "1" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "ScheduledInstallDay" -Value "0" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "ScheduledInstallTime" -Value "3" -OutVariable "tmp"
- New-ItemProperty -Path $wsus_path2 -PropertyType DWORD -Force -Name "UseWUServer" -Value "1" -OutVariable "tmp"
- Write-Host "----- Results of Registry update"
- Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -OutVariable "tmp"
- Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -OutVariable "tmp"
- write-host $tmp
- Start-Service -name "msiserver"
- Start-Service -name "bits"
- Start-Service -name "cryptSvc"
- Set-Service "WUAUSERV" -StartupType Automatic
- Start-Service -name "WUAUSERV"
- wuauclt /resetauthorization
- wuauclt /detectnow
- wuauclt /reportnow
- start "$env:windir\system32\perfmon.exe" /res
- (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
- explorer.exe "ms-settings:windowsupdate"
- Write-Host "------WSUS Config Script End------"
- # Create a regfile on desktop that disables WSUS
- echo "Windows Registry Editor Version 5.00"> "C:\users\$env:username\desktop\removewsus.reg"
- echo "">> "C:\users\$env:username\desktop\removewsus.reg"
- echo "[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]">> "C:\users\$env:username\desktop\removewsus.reg"
- echo '"UseWUServer"=dword:00000000'>> "C:\users\$env:username\desktop\removewsus.reg"
- # Run windows' clean manager to create a profile
- start-process -Filepath "cleanmgr.exe" -ArgumentList "/sageset:11"
- write-host
- write-host ~~~ Map Z
- write-host
- net use A: /delete
- net use B: /delete
- net use A: \\195.1.1.53\Pub
- net use B: '\\195.1.1.13\p&f_data' /user:domain\username password /persistent:yes
- pause
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Personalisation, Disable Telemetry and Pre-Installed Adware
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search\"
- $Name = "BingSearchEnabled"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Policies\Microsoft\Windows\Explorer\"
- $Name = "HidePeopleBar"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Internet Explorer\MINIE"
- $Name = "LinksBandEnabled"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search"
- $Name = "SearchboxTaskbarMode"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- $Name = "ShowTaskViewButton"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Internet Explorer\Main"
- $Name = "Start Page"
- $value = "https://rdswelcomepage.company.co.uk"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- $Name = "TaskbarSmallIcons"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer"
- $Name = "DisableNotificationCenter"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer"
- $Name = "EnableAutoTray"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\Shell\Bags\1\Desktop"
- $Name = "40200225"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
- $Name = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu"
- $Name = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
- $Name = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu"
- $Name = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy"
- $Name = "LetAppsRunInBackground"
- $value = "2"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- $Name = "MMTaskbarEnabled"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- $Name = "TaskbarGlomLevel"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- $Name = "MMTaskbarGlomLevel"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
- $Name = "EnableLUA"
- $value = "0"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- } ELSE {
- New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
- $Name = "FeatureManagementEnabled", "OemPreInstalledAppsEnabled", "RotatingLockScreenEnabled", "RotatingLockScreenOverlayEnabled", "SilentInstalledAppsEnabled", "SystemPaneSuggestionsEnabled", "PreInstalledAppsEnabled", "SoftLandingEnabled", "SubscribedContentEnabled", "PreInstalledAppsEverEnabled", "ContentDeliveryAllowed"
- $value = "0", "0", "1", "1", "0", "0", "0", "0", "1", "1", "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- }
- $i=0
- foreach ($entry in $Name) {
- New-ItemProperty -Path $registryPath -Name $entry -Value $value[$i] -PropertyType DWORD -Force | Out-Null
- $i++
- }
- $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization"
- $Name = "DODownloadMode"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- }
- foreach ($entry in $Name) {
- New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10001"
- $Name = "*"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- }
- foreach ($entry in $Name) {
- New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10001"
- $Name = "*"
- $value = "195.1.1.13"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- }
- foreach ($entry in $Name) {
- New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType String -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10002"
- $Name = "*"
- $value = "1"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- }
- foreach ($entry in $Name) {
- New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType DWORD -Force | Out-Null
- }
- $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10002"
- $Name = "*"
- $value = "195.1.1.167"
- IF(!(Test-Path $registryPath))
- {
- New-Item -Path $registryPath -Force | Out-Null
- }
- foreach ($entry in $Name) {
- New-ItemProperty -Path $registryPath -Name $entry -Value $value -PropertyType String -Force | Out-Null
- }
- write-host Done.
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Unistalling Oracle Java
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- Write-Host "Getting Java GUIDs"
- $javaGUID = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like 'Java 8*'} | select -ExpandProperty IdentifyingNumber
- Write-Host "Found : $javaGUID"
- foreach ($guid in $JavaGUID) { write-host "Uninstalling Java with ID $guid"; start-process -filepath msiexec -argumentlist "/x $guid /qn" -wait}
- Echo "Done."
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Forcing en-GB Only
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- Set-WinUserLanguageList -Force 'en-GB'
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Creating Ultimate Power mode
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61
- $powerPlan = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerPlan -Filter "ElementName = 'Ultimate Performance'"
- $powerPlan.Activate()
- powercfg.exe /h off
- powercfg -change -monitor-timeout-ac 20
- powercfg -change -standby-timeout-ac 20
- powercfg -change -hibernate-timeout-ac 20
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Disabling Scheduled Defrag
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- If ((Get-ScheduledTask -TaskName 'ScheduledDefrag').State -eq 'Ready')
- {
- Disable-ScheduledTask -TaskName 'ScheduledDefrag' -TaskPath '\Microsoft\Windows\Defrag'
- }
- Get-ScheduledTask -TaskName 'ScheduledDefrag'
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Enabling Windows Feature: .Net3
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- DISM.EXE /Online /Add-Capability /CapabilityName:NetFx3~~~~
- Add-WindowsCapability -Online -Name NetFx3~~~~
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Get remote files
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- if ($dev_type -eq "laptop") {
- $zcp="A:\cp_laptops" } ELSE {
- $zcp="A:\cp"
- }
- IF((Test-Path $cppath))
- {
- remove-item -recurse -force -Path $cppath
- } ELSE {
- mkdir "$cppath"
- }
- xcopy /E /Y /I $zcp "C:\cp"
- # Set wallpaper
- mkdir "C:\wallpaper"
- xcopy /E /Y /I "A:\deploy\Wallpaper" "C:\wallpaper"
- & "C:\wallpaper\binary\WallpaperChanger.exe" "C:\wallpaper\image\company.png" 1
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Uninstall OneDrive
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- write-host Closing OneDrive process.
- write-host
- taskkill /f /im OneDrive.exe
- Start-Sleep -s 5
- write-host Uninstalling OneDrive.
- write-host
- IF((Test-Path $x64))
- {
- start-process -filepath "C:\windows\SysWOW64\OneDriveSetup.exe" -ArgumentList '/uninstall'
- } else {
- start-process -filepath "C:\windows\System32\OneDriveSetup.exe" -ArgumentList '/uninstall'
- }
- Start-Sleep -s 5
- write-host Removing OneDrive leftovers.
- write-host
- remove-item -recurse -force -Path "$env:userprofile\OneDrive"
- remove-item -recurse -force -Path "C:\OneDriveTemp"
- remove-item -recurse -force -Path "$env:localappdata\Microsoft\OneDrive"
- remove-item -recurse -force -Path "C:\programdata\Microsoft OneDrive"
- write-host Removing OneDrive from the Explorer Side Panel.
- write-host
- REG DELETE "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
- REG DELETE "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Uninstall GetOffice
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- IF((Test-Path $getoffice)) {
- 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"
- 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"
- 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"
- } ELSE {
- write-host GetOffice not found
- write-host
- }
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ De-Bloat
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- taskkill /f /im explorer.exe
- write-host Lenovo Apps
- Get-AppxPackage *lenov* | Remove-AppxPackage
- write-host Dell Apps
- Get-AppxPackage *dell* | Remove-AppxPackage
- write-host Disney
- Get-AppxPackage *disn* | Remove-AppxPackage
- write-host Bubble Witch
- Get-AppxPackage *bubbl* | Remove-AppxPackage
- write-host March of Empires
- Get-AppxPackage *march* | Remove-AppxPackage
- write-host McAfee
- Get-AppxPackage *mcaf* | Remove-AppxPackage
- write-host 3D Builder
- Get-AppxPackage *3dbuilder* | Remove-AppxPackage
- write-host Camera
- Get-AppxPackage *windowscamera* | Remove-AppxPackage
- write-host GetSkype
- Get-AppxPackage *skype* | Remove-AppxPackage
- write-host Spotify
- Get-AppxPackage *spotif* | Remove-AppxPackage
- write-host Cyberlink
- Get-AppxPackage *cyberl* | Remove-AppxPackage
- write-host GetStarted
- Get-AppxPackage *getstarted* | Remove-AppxPackage
- write-host Zune
- Get-AppxPackage *zunemusic* | Remove-AppxPackage
- write-host Maps
- Get-AppxPackage *windowsmaps* | Remove-AppxPackage
- write-host Money
- Get-AppxPackage *bingfinance* | Remove-AppxPackage
- write-host OneNote
- Get-AppxPackage *onenote* | Remove-AppxPackage
- write-host News
- Get-AppxPackage *bingnews* | Remove-AppxPackage
- write-host Sports
- Get-AppxPackage *bingsports* | Remove-AppxPackage
- write-host Sketchbook
- Get-AppxPackage *sketc* | Remove-AppxPackage
- write-host Weather
- Get-AppxPackage *bingweather* | Remove-AppxPackage
- write-host xboxapp
- Get-AppxPackage *xboxapp* | Remove-AppxPackage
- write-host Twitter
- Get-AppxPackage *twitter* | Remove-AppxPackage
- write-host Minecraft
- Get-AppxPackage *minec* | Remove-AppxPackage
- write-host Candy Crush
- Get-AppxPackage *candy* | Remove-AppxPackage
- write-host Plex
- Get-AppxPackage *plex* | Remove-AppxPackage
- write-host Keeper Security
- Get-AppxPackage *keep* | Remove-AppxPackage
- write-host Feedback hub
- Get-AppxPackage *feed* | Remove-AppxPackage
- write-host Films and TV
- Get-AppxPackage *film* | Remove-AppxPackage
- write-host Messaging
- Get-AppxPackage *messaging* | Remove-AppxPackage
- write-host Paid wifi and mobile
- Get-AppxPackage *paid* | Remove-AppxPackage
- write-host Xbox Apps
- Get-AppxPackage *xbox* | Remove-AppxPackage
- write-host Netflix
- Get-AppxPackage *netfli* | Remove-AppxPackage
- write-host Skype
- Get-AppxPackage *skype* | Remove-AppxPackage
- write-host Dolby Sound
- Get-AppxPackage *dolby* | Remove-AppxPackage
- write-host Fitbit Coach
- Get-AppxPackage *fitbit* | Remove-AppxPackage
- write-host Phototastic
- Get-AppxPackage *photota* | Remove-AppxPackage
- write-host Cookin Fever
- Get-AppxPackage *fever* | Remove-AppxPackage
- write-host Skype-Online
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*skype*"} | remove-appxprovisionedpackage -online
- write-host Sketch
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*sketch*"} | remove-appxprovisionedpackage -online
- write-host People
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*people*"} | remove-appxprovisionedpackage -online
- write-host Print3D
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*print3d*"} | remove-appxprovisionedpackage -online
- write-host Office-Online
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*office*"} | remove-appxprovisionedpackage -online
- write-host MixedReality
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*mixedreality*"} | remove-appxprovisionedpackage -online
- write-host 3DViewer
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*3dviewer*"} | remove-appxprovisionedpackage -online
- write-host Messaging
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*messaging*"} | remove-appxprovisionedpackage -online
- write-host Bing
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*bing*"} | remove-appxprovisionedpackage -online
- write-host Zune
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*zune*"} | remove-appxprovisionedpackage -online
- write-host Phone
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*phone*"} | remove-appxprovisionedpackage -online
- write-host Maps
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*maps*"} | remove-appxprovisionedpackage -online
- write-host Camera
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*camera*"} | remove-appxprovisionedpackage -online
- write-host Alarm
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*alarm*"} | remove-appxprovisionedpackage -online
- write-host Wallet
- Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*wallet*"} | remove-appxprovisionedpackage -online
- write-host Farm*
- Get-AppxPackage *farm* | Remove-AppxPackage
- write-host Cookin Fever
- Get-AppxPackage *fever* | Remove-AppxPackage
- start explorer.exe
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Firewall Config
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- if ($dev_type -eq "desktop") {
- $fw="off"
- } elseif ($dev_type -eq "laptop") {
- $fw="on"
- }
- netsh advfirewall set allprofiles state $fw
- write-host
- write-host ~~~ Install Chocolatey - SetPoint - Chrome - Acrobat Reader - Air - Silverlight - 7Zip - WinRar - Notepad++ - Flash - Firefox ESR - Zoom
- write-host
- Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- choco upgrade setpoint googlechrome adobereader adobeair 7zip winrar notepadplusplus flashplayerppapi firefoxesr zoom -y
- write-host
- write-host ~~~ Remove addons from Chrome
- write-host
- cls
- if ($dev_type -eq "laptop") {
- choco upgrade antivirusfreeantivirus -y
- $chrome_cleanup="", "ghbmnnjooekpmoecnnnilnnbdlolhkhi", "bkiaicqvmhfslxrmjdgzobufxqnmcvyk", "bkiaicqvmhfslxrmjdgzobufxqnmcvyk", "bkiaicqvmhfslxrmjdgzobufxqnmcvyk"
- $chrome_cleanup | foreach { remove-item -Path "$env:localappdata\Google\Chrome\User Data\Default\Extensions\$_" -force -Recurse }
- }
- write-host
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host ~~~ Installing BleachBit
- write-host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- write-host
- IF((Test-Path -Path "$bbpath")) {
- remove-item -recurse -force -Path "$bbpath"
- remove-item -recurse -force -Path "$bbpath"
- } ELSE {
- write-host clean install
- }
- mkdir "$bbpath"
- xcopy /E /Y /I "A:\deploy\bb" "$bbpath"
- & "C:\Program Files\WinRAR\WinRAR.exe" x -o+ "$bbpath\BleachB.rar" "$bbpath"
- start-sleep -s 10
- remove-item -recurse -force -Path "$bbpath\BleachB.rar"
- write-host
- write-host ~~~ Run Bleach Bit
- write-host
- Start-Process -Wait -FilePath "C:\Program Files\BleachB\bleachbit.exe" -ArgumentList "-c --preset"
- Refresh-Environment
- write-host
- write-host ~~~ Device specific configs
- write-host
- if ($dev_type -eq "desktop") {
- write-host ~~~ Writing Hosts File
- Add-Content C:\windows\system32\drivers\etc\hosts "195.1.1.190 remote.company.co.uk"
- #Telegraf
- $archive="telegraf-desktop.rar"
- $telegraf_path="C:\Program Files\telegraf"
- if (Test-Path $telegraf_path) {
- C:\"Program Files"\Telegraf\telegraf.exe --service uninstall
- Stop-Service Telegraf
- $service = Get-WmiObject -Class Win32_Service -Filter "Name='Telegraf'"
- $service.delete()
- Remove-Item -Path $telegraf_path -Force -Recurse
- }
- mkdir "$telegraf_path"
- if (!(Test-Path "C:\Program Files\7-Zip\7z.exe")) {
- xcopy /E /Y /I "A:\Deploy\7z" "$telegraf_path"
- start-process -Wait -FilePath "$telegraf_path\7z-Installer.exe" -ArgumentList "/S"
- }
- Copy-Item -Path "A:\deploy\telegraf-agent\$archive" -Destination "$telegraf_path\telegraf.rar" -Force
- cd "$telegraf_path"
- start-process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList 'e "C:\Program Files\telegraf\telegraf.rar"'
- start-sleep -s 4
- remove-item -recurse -force -Path "$telegraf_path\telegraf.rar"
- C:\"Program Files"\Telegraf\telegraf.exe --service install
- Get-Service telegraf* | Start-Service
- sc.exe config telegraf start=delayed-auto
- } elseif ($dev_type -eq "laptop") {
- Remove-Item -Path HKLM:\SOFTWARE\Policies\Lenovo\ -Force -Recurse
- write-host ~~~ Update/Login - VPNclient
- iwr -uri "https://static.VPNclient.com/apps/windows/VPNclient.exe" -outfile "C:\cp\vpn.exe"
- start-process -wait "C:\cp\vpn.exe" -ArgumentList "/S"
- choco upgrade antivirus
- $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
- $wifis_rec=$wifis
- Write-Host $wifis
- Function Remove-WIFIProfile($SSID)
- {
- (NETSH WLAN DELETE PROFILE NAME=$SSID)
- }
- $SSIDList=(NETSH WLAN SHOW PROFILE) | Select-String 'All User Profile'
- $wifis=$SSIDList | Foreach { [pscustomobject]@{SSID=$_.line.substring(27) }}
- $wifis
- $wifis | foreach { $tmp=$_.ssid
- if ($tmp -notlike "*company*") {
- Remove-WIFIProfile -ssid $tmp
- }
- }
- $wifis
- pause
- }
- write-host
- write-host ~~~ Setup portlocker
- write-host
- $portlocker_path="C:\program files\portlocker"
- IF(!(Test-Path "$portlocker_path"))
- {
- mkdir "C:\program files\portlocker"
- xcopy /E /Y /I "C:\cp\portlocker" "C:\program files\portlocker"
- start-process -wait "C:\program files\portlocker\portlocker.exe"
- } ELSE {
- write-host portlocker is already installed
- start-process -wait "C:\program files\portlocker\portlocker.exe"
- }
- cls
- write-host
- write-host ~~~ Clean up Desktop, downloads
- write-host
- mkdir "C:\update_backups\desktop"
- mkdir "C:\update_backups\downloads"
- xcopy /E /Y /I "C:\Users\$env:username\Desktop" "C:\update_backups\desktop"
- remove-item -recurse -force -Path "C:\Users\$env:username\Desktop"
- mkdir "C:\Users\$env:username\Desktop"
- xcopy /E /Y /I "C:\Users\Public\Desktop" "C:\update_backups\desktop"
- remove-item -recurse -force -Path "C:\Users\Public\Desktop"
- remove-item -recurse -force -Path "C:\Users\Public\Desktop"
- mkdir "C:\Users\Public\Desktop"
- xcopy /E /Y /I "C:\Users\$env:username\Downloads" "C:\update_backups\downloads"
- remove-item -recurse -force -Path "C:\Users\$env:username\Downloads"
- remove-item -recurse -force -Path "C:\Users\$env:username\Downloads"
- mkdir "C:\Users\$env:username\Downloads"
- Move-Item "C:\cp\media\company.ico" -Destination "C:\windows\company.ico" -Force
- if ($dev_type -eq "desktop") {
- $shortcuts="B:\it\desktop_shortcuts"
- } elseif ($dev_type -eq "laptop") {
- $shortcuts="B:\it\laptop_shortcuts"
- }
- xcopy /E /Y /I $shortcuts "C:\Users\$env:username\Desktop"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Winr*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Mozi*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Goog*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Inter*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Acro*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Note*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\CCl*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Phone*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Passwordm*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Snip*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Firef*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\scansna*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Deskt*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\VPNclient*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\antivirus*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Firefox*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Media*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Scan*.lnk"
- remove-item -recurse -force -Path "C:\update_backups\desktop\*Edge*"
- remove-item -recurse -force -Path "C:\update_backups\desktop\Zoom*"
- remove-item -recurse -force -Path "C:\update_backups\desktop\removewsus.reg"
- remove-item -recurse -force -Path $cppath
- # Write Log
- $timestamp = Get-Date -Format "dddd_MM_dd_yyyy_HH_mm"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "------------------------------"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Date Executed"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $timestamp
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Determined location"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $loc
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Computer name"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $env:Computername
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "IPs"
- $theip="$ipis" + "$ipis_b"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $theip
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
- $os_Version=[environment]::OSVersion.Version
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "OS Version"
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $os_Version
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
- if ($dev_type -eq "laptop") {
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "Saved WiFi Networks"
- $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
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" $wifis_rec
- Add-Content "\\195.1.1.53\Pub\Reports\$dev_type\Updates\$env:computername.txt" "-------"
- }
- # Cleanup
- net stop WUAUSERV
- remove-item -recurse -force -Path "C:\Windows\SoftwareDistribution"
- net use /delete B:
- net use /delete A:
- Write-Host "Dism Cleanup"
- Dism.exe /online /cleanup-image /startcomponentcleanup
- start-process -Filepath "cleanmgr.exe" -ArgumentList "/sagerun:11" -wait
- Start-Process -Wait -FilePath "C:\Program Files\BleachB\bleachbit.exe" -ArgumentList "-c --preset"
- net start WUAUSERV
- start-process -FilePath 'C:\Program Files\internet explorer\iexplore.exe'
- pause
- start-process -FilePath 'shutdown.exe' -ArgumentList '-r -t 5'
- remove-item -force -Path 'C:\*.bat'
- remove-item -force -Path 'C:\*.ps1'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement