From e1c290363884d04675be99ce9dc5776e7f532e4c Mon Sep 17 00:00:00 2001
From: Andreas Lindemark <andli86@c.itn.liu.se>
Date: Fri, 13 Dec 2019 20:01:09 +0100
Subject: [PATCH] Lots of changes and additions

---
 README.md                                     |  3 +-
 Windows/Activate_PowerShell_Scripts.ps1       |  1 +
 Windows/Choco_Check_Outdated_and_Upgrade.ps1  |  8 +++++
 Windows/Choco_Install_Chocolatey.ps1          |  2 ++
 Windows/Choco_Install_Misc_Programs.ps1       | 33 +++++++++++++++++++
 ...ISM_online_cleanup-image_restorehealth.cmd |  3 +-
 .../Disable Telemetry and Data Collection.cmd |  4 ---
 .../Disable_Telemetry_and_Data_Collection.cmd |  4 +++
 Windows/Install_dotNET_FrameWork_3.5.cmd      | 22 +++++++++++++
 Windows/List Microsoft Apps & Bloatware.ps1   |  3 --
 Windows/List_Microsoft_Apps_and_Bloatware.ps1 |  3 ++
 Windows/OS-info_Windows10.ps1                 | 20 +++++++++++
 ...> Remove_Microsoft_Apps_and_Bloatware.ps1} |  2 +-
 ...rive.cmd => Remove_Microsoft_OneDrive.cmd} | 12 +++----
 Windows/SFC_scannow.cmd                       |  3 +-
 Windows/WSUS_fix.cmd                          | 28 ++++++++--------
 Windows/WSUS_run.cmd                          |  4 +--
 17 files changed, 122 insertions(+), 33 deletions(-)
 create mode 100644 Windows/Activate_PowerShell_Scripts.ps1
 create mode 100644 Windows/Choco_Check_Outdated_and_Upgrade.ps1
 create mode 100644 Windows/Choco_Install_Chocolatey.ps1
 create mode 100644 Windows/Choco_Install_Misc_Programs.ps1
 delete mode 100644 Windows/Disable Telemetry and Data Collection.cmd
 create mode 100644 Windows/Disable_Telemetry_and_Data_Collection.cmd
 create mode 100644 Windows/Install_dotNET_FrameWork_3.5.cmd
 delete mode 100644 Windows/List Microsoft Apps & Bloatware.ps1
 create mode 100644 Windows/List_Microsoft_Apps_and_Bloatware.ps1
 create mode 100644 Windows/OS-info_Windows10.ps1
 rename Windows/{Remove Microsoft Bloatware.ps1 => Remove_Microsoft_Apps_and_Bloatware.ps1} (99%)
 rename Windows/{Remove Microsoft OneDrive.cmd => Remove_Microsoft_OneDrive.cmd} (82%)

diff --git a/README.md b/README.md
index 7593423..3d4bbfd 100644
--- a/README.md
+++ b/README.md
@@ -3,4 +3,5 @@
 Code Snippets
 
 Run these snippets on your own risk!
-It's your responsibility to understand what these snippets do.
\ No newline at end of file
+
+It's your own responsibility to understand what these snippets do.
\ No newline at end of file
diff --git a/Windows/Activate_PowerShell_Scripts.ps1 b/Windows/Activate_PowerShell_Scripts.ps1
new file mode 100644
index 0000000..4d10bbc
--- /dev/null
+++ b/Windows/Activate_PowerShell_Scripts.ps1
@@ -0,0 +1 @@
+Set-ExecutionPolicy Unrestricted
\ No newline at end of file
diff --git a/Windows/Choco_Check_Outdated_and_Upgrade.ps1 b/Windows/Choco_Check_Outdated_and_Upgrade.ps1
new file mode 100644
index 0000000..f878d69
--- /dev/null
+++ b/Windows/Choco_Check_Outdated_and_Upgrade.ps1
@@ -0,0 +1,8 @@
+# Chocolatey check which programs that is outdated and can be upgraded
+choco outdated
+
+# Chocolatey dry-run upgrade all programs (dry run = no upgrade is done)
+choco upgrade -y all --noop
+
+# Chocolatey upgrade all programs
+choco upgrade -y all
\ No newline at end of file
diff --git a/Windows/Choco_Install_Chocolatey.ps1 b/Windows/Choco_Install_Chocolatey.ps1
new file mode 100644
index 0000000..9626bdc
--- /dev/null
+++ b/Windows/Choco_Install_Chocolatey.ps1
@@ -0,0 +1,2 @@
+# Install Chocolatey
+Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object  System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
\ No newline at end of file
diff --git a/Windows/Choco_Install_Misc_Programs.ps1 b/Windows/Choco_Install_Misc_Programs.ps1
new file mode 100644
index 0000000..d4dd9cc
--- /dev/null
+++ b/Windows/Choco_Install_Misc_Programs.ps1
@@ -0,0 +1,33 @@
+# Install programs with the help from Chocolatey
+# Enable/Disable what you what to install or not
+
+# Install 7zip
+choco install -y 7zip.install
+
+# Install Adobe Reader
+choco install -y adobereader
+
+# Install ShutUp10
+choco install -y shutup10
+
+# Install Veeam Agent
+choco install -y veeam-agent
+
+# Install VNC-connect
+choco install -y vnc-connect
+
+# Install VNC-connect
+choco install -y vnc-viewer
+
+# Install the Zabbix Agent via Chocolatey
+choco Install -y zabbix-agent --force
+
+# Configure the Zabbix Agent service
+Set-Service -Name "Zabbix Agent" -StartupType Automatic
+SC.exe failure "Zabbix Agent" actions= restart/60000/restart/60000/restart/60000 reset= 0
+
+# Start the Zabbix Agent service if it's not running
+Start-Service -Name "Zabbix Agent"
+
+# Check the Zabbix Agent service status
+Get-Service "Zabbix Agent" | Select-Object -Property Name, StartType, Status
\ No newline at end of file
diff --git a/Windows/DISM_online_cleanup-image_restorehealth.cmd b/Windows/DISM_online_cleanup-image_restorehealth.cmd
index 201a5e8..6b80ebf 100644
--- a/Windows/DISM_online_cleanup-image_restorehealth.cmd
+++ b/Windows/DISM_online_cleanup-image_restorehealth.cmd
@@ -1,2 +1,3 @@
 DISM.exe /Online /Cleanup-image /Restorehealth
-pause
\ No newline at end of file
+
+PAUSE
\ No newline at end of file
diff --git a/Windows/Disable Telemetry and Data Collection.cmd b/Windows/Disable Telemetry and Data Collection.cmd
deleted file mode 100644
index b6b9c37..0000000
--- a/Windows/Disable Telemetry and Data Collection.cmd	
+++ /dev/null
@@ -1,4 +0,0 @@
-sc delete DiagTrack
-echo "" > C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl
-reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
-sc delete dmwappushservice
\ No newline at end of file
diff --git a/Windows/Disable_Telemetry_and_Data_Collection.cmd b/Windows/Disable_Telemetry_and_Data_Collection.cmd
new file mode 100644
index 0000000..24c01dc
--- /dev/null
+++ b/Windows/Disable_Telemetry_and_Data_Collection.cmd
@@ -0,0 +1,4 @@
+SC delete DiagTrack
+ECHO "" > C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl
+REG add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f
+SC delete dmwappushservice
\ No newline at end of file
diff --git a/Windows/Install_dotNET_FrameWork_3.5.cmd b/Windows/Install_dotNET_FrameWork_3.5.cmd
new file mode 100644
index 0000000..d9b8668
--- /dev/null
+++ b/Windows/Install_dotNET_FrameWork_3.5.cmd
@@ -0,0 +1,22 @@
+: Specify path to \sources\sxs (for the right version of Windows 10)
+SET PATH="%1"
+
+: Check that \sources\sxs exist
+IF NOT EXIST %PATH% GOTO :FAILED
+
+: Check that \sources\sxs\*netfx3* and \sources\sxs\*NetFx3* exist
+IF NOT EXIST %PATH%\*netfx3* GOTO :FAILED
+IF NOT EXIST %PATH%\*NetFx3* GOTO :FAILED
+
+: Install .NET Framework 3.5 (incl. 2.0 and 3.0)
+DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:%PATH%
+GOTO :END
+
+:FAILED
+ECHO Something went wrong!
+EXIT /B 99
+
+:END
+EXIT /B 0
+
+:EOF
\ No newline at end of file
diff --git a/Windows/List Microsoft Apps & Bloatware.ps1 b/Windows/List Microsoft Apps & Bloatware.ps1
deleted file mode 100644
index f735c82..0000000
--- a/Windows/List Microsoft Apps & Bloatware.ps1	
+++ /dev/null
@@ -1,3 +0,0 @@
-CLS
-
-Get-AppxPackage | Select Name, PackageFullName
\ No newline at end of file
diff --git a/Windows/List_Microsoft_Apps_and_Bloatware.ps1 b/Windows/List_Microsoft_Apps_and_Bloatware.ps1
new file mode 100644
index 0000000..d9cdd64
--- /dev/null
+++ b/Windows/List_Microsoft_Apps_and_Bloatware.ps1
@@ -0,0 +1,3 @@
+Clear-Host
+
+Get-AppxPackage | Select-Object Name, PackageFullName
\ No newline at end of file
diff --git a/Windows/OS-info_Windows10.ps1 b/Windows/OS-info_Windows10.ps1
new file mode 100644
index 0000000..16f819b
--- /dev/null
+++ b/Windows/OS-info_Windows10.ps1
@@ -0,0 +1,20 @@
+# Windows 10 procuct lifecycle info, comes from these Microsoft support pages...
+# https://support.microsoft.com/en-us/help/13853/windows-lifecycle-fact-sheet
+# https://support.microsoft.com/en-us/lifecycle/search/
+
+$Computer = "localhost"
+$os = Get-WmiObject -class Win32_OperatingSystem -ComputerName $Computer | Select-Object Caption,Version
+switch($os.Version){
+'10.0.10240'{$update="1507"; $supported_until="2017-05-09"}
+'10.0.10586'{$update="1511"; $supported_until="2017-10-10"}
+'10.0.14393'{$update="1607"; $supported_until="2019-04-09"}
+'10.0.15063'{$update="1703"; $supported_until="2019-10-08"}
+'10.0.16299'{$update="1709"; $supported_until="2020-04-14"}
+'10.0.17134'{$update="1803"; $supported_until="2020-11-10"}
+'10.0.17763'{$update="1809"; $supported_until="2021-05-11"}
+'10.0.18362'{$update="1903"; $supported_until="2020-12-08"}
+'10.0.18363'{$update="1909"; $supported_until="2022-05-10"}
+}
+Write-Output "$($os.Caption) $update"
+Write-Output "$($os.Version)"
+Write-Output "$supported_until"
\ No newline at end of file
diff --git a/Windows/Remove Microsoft Bloatware.ps1 b/Windows/Remove_Microsoft_Apps_and_Bloatware.ps1
similarity index 99%
rename from Windows/Remove Microsoft Bloatware.ps1
rename to Windows/Remove_Microsoft_Apps_and_Bloatware.ps1
index f07363a..df24fa1 100644
--- a/Windows/Remove Microsoft Bloatware.ps1	
+++ b/Windows/Remove_Microsoft_Apps_and_Bloatware.ps1
@@ -1,4 +1,4 @@
-CLS
+Clear-Host
 
 $AppsList =
 
diff --git a/Windows/Remove Microsoft OneDrive.cmd b/Windows/Remove_Microsoft_OneDrive.cmd
similarity index 82%
rename from Windows/Remove Microsoft OneDrive.cmd
rename to Windows/Remove_Microsoft_OneDrive.cmd
index c6974b3..80ac6f0 100644
--- a/Windows/Remove Microsoft OneDrive.cmd	
+++ b/Windows/Remove_Microsoft_OneDrive.cmd
@@ -8,22 +8,22 @@ GOTO :EOF
 
 :32BIT
 :: Terminate any process of OneDrive and Uninstall OneDrive on 32-bit Windows 10
-taskkill /f /im OneDrive.exe
+TASKKILL /f /im OneDrive.exe
 %SystemRoot%\System32\OneDriveSetup.exe /uninstall
 
 :64BIT
 :: Terminate any process of OneDrive and Uninstall OneDrive on 64-bit Windows 10
-taskkill /f /im OneDrive.exe
+TASKKILL /f /im OneDrive.exe
 %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
 
 :: Turn off OneDrive everywhere completely via the Registry
 REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive" /v DisableFileSyncNGSC /t REG_DWORD /d 1 /f
 
 :: Cleaning and Removing OneDrive Remnants
-rd "%UserProfile%\OneDrive" /Q /S
-rd "%LocalAppData%\Microsoft\OneDrive" /Q /S
-rd "%ProgramData%\Microsoft OneDrive" /Q /S
-rd "C:\OneDriveTemp" /Q /S
+RD "%UserProfile%\OneDrive" /Q /S
+RD "%LocalAppData%\Microsoft\OneDrive" /Q /S
+RD "%ProgramData%\Microsoft OneDrive" /Q /S
+RD "C:\OneDriveTemp" /Q /S
 
 :: Delete and Remove OneDrive in File Explorer Folder Tree Registry Key
 REG DELETE "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
diff --git a/Windows/SFC_scannow.cmd b/Windows/SFC_scannow.cmd
index 3d0a0c9..a24c697 100644
--- a/Windows/SFC_scannow.cmd
+++ b/Windows/SFC_scannow.cmd
@@ -1,2 +1,3 @@
 SFC /scannow
-pause
\ No newline at end of file
+
+PAUSE
\ No newline at end of file
diff --git a/Windows/WSUS_fix.cmd b/Windows/WSUS_fix.cmd
index 2e13c9c..e0e4bbd 100644
--- a/Windows/WSUS_fix.cmd
+++ b/Windows/WSUS_fix.cmd
@@ -1,28 +1,28 @@
 :: Stop Services
-net stop bits
-net stop cryptsvc
-net stop wuauserv
+NET stop bits
+NET stop cryptsvc
+NET stop wuauserv
 
 :: Delete Registry keys
-reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f
-reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f
-reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
-reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientIDValidation /f
+REG delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f
+REG delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f
+REG delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
+REG delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientIDValidation /f
 
 :: Delete Directories
-rd /s /q "C:\WINDOWS\SoftwareDistribution"
-rd /s /q "C:\WINDOWS\System32\catroot2"
+RD /s /q "C:\WINDOWS\SoftwareDistribution"
+RD /s /q "C:\WINDOWS\System32\catroot2"
 
 :: Start Services
-net start bits
-net start cryptsvc
-net start wuauserv
+NET start bits
+NET start cryptsvc
+NET start wuauserv
 
 :: Force a detection event to the assinged WSUS server
-wuauclt /resetauthorization /detectnow
+WUAUCLT /resetauthorization /detectnow
 
 :: Force Windows Update to contact the WSUS server
 PowerShell.exe (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
 
 :: Report to WSUS (if there is something to report)
-wuauclt /reportnow
\ No newline at end of file
+WUAUCLT /reportnow
\ No newline at end of file
diff --git a/Windows/WSUS_run.cmd b/Windows/WSUS_run.cmd
index e32f65a..dfa4b8d 100644
--- a/Windows/WSUS_run.cmd
+++ b/Windows/WSUS_run.cmd
@@ -1,8 +1,8 @@
 :: Force a detection event to the assinged WSUS server
-wuauclt /resetauthorization /detectnow
+WUAUCLT /resetauthorization /detectnow
 
 :: Force Windows Update to contact the WSUS server
 PowerShell.exe (New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
 
 :: Report to WSUS (if there is something to report)
-wuauclt /reportnow
\ No newline at end of file
+WUAUCLT /reportnow
\ No newline at end of file
-- 
GitLab