NewDevicePrep

Published on 4 June 2021 at 11:39

Reason

This script was made to aid myself or other IT colleagues to help install all required software on a new device.
A complete setup from scratch might take up to 30 min instead of half a day.

It started with a small list of executables in the script, but some failed because of another installer being busy.
Here was an opportunity to add some required intervention to push on a key.

A log file was created to get the system info and also if needed to troubleshoot where the script failed.
Try catch was used to log the failed parts while able to continue the script.

some names were adjusted (servers/inhouse software/company name).

Please use parts of this script with caution, I am not responsible for any damage.

script

<#
names and references to company were deleted/renamed like <servername> for the server
------
first setup make test account without password
------
1) Join device to domain with admin account
2) Rename device
3) Reboot
------
1) log in with admin account
2) enable powershell scripts "set-executionpolicy remotesigned" type Y
3) reboot
------
Run script.
------
Post script:
1) import device in monitoring system
2) activate Anti-virus
------
Logfile can be found at '\\<servername>\Software\General\Log$\NewDevice$\
#>
# [1] Creating log file
try{
New-Item \\<servername>\Software\General\Log$\NewDevice$\$env:COMPUTERNAME-info.txt
write-host "logfile has been created"
}
catch {
write-host "file might already exist"
}
try {
Write-Progress -Activity '<company> install script 8%' -Status 'Creating Logfile' -PercentComplete 8
$log = "\\<servername>\Software\General\Log$\NewDevice$\$env:COMPUTERNAME-info.txt"
'[1] Logfile created' >> $log
Get-ComputerInfo -Property csdnshostname,biosseralnumber,csmodel,osarchitecture,cssystemskunumber >> $log
#progressbar
}
catch{
write-host 'Failed to create logfile'
Write-Host 'Press any key to continue without logfile';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
}
# [2] Adding WIFI profile
try {
Write-Progress -Activity '<company> install script 16%' -Status 'Adding WIFI profile' -PercentComplete 16
'[2] Added <company> Wifi profile' >> $log
netsh wlan add profile filename='\\<servername>\Software\General\scripts\<company>_WIFI.xml'
}
catch {
'[2] <ERROR> Failed to Add <company> Wifi profile' >> $log
}
# [3] Enabling NumLock on start
try {
Write-Progress -Activity '<company> install script 24%' -Status 'Enabling NumLock' -PercentComplete 24
'[3] Enabled Numlock on startup' >> $log
Set-ItemProperty -Path 'Registry::HKU\.DEFAULT\Control Panel\Keyboard' -Name 'InitialKeyboardIndicators' -Value '2147483650'
Set-ItemProperty -Path 'HKCU:\Control Panel\Keyboard' -Name 'InitialKeyboardIndicators' -Value '2147483650'
}
catch {
'[3] <ERROR> Failed to enable Numlock on startup' >> $log
}
# [4] Disable Fastboot
try {
Write-Progress -Activity '<company> install script 32%' -Status 'Disable Fastboot' -PercentComplete 32
'[4] Disabled Fastboot' >> $log
REG ADD 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Power' /v HiberbootEnabled /t REG_DWORD /d '0' /f
}
catch {
'[4] <ERROR> Failed to disable fastboot' >> $log
}
# [5] Renaming Test account to <local admin account>, set password
try {
Write-Progress -Activity '<company> install script 40%' -Status 'Renaming Test account' -PercentComplete 40
#Check for test account and rename
$USERNAME = "Test"
if((Get-LocalUser $USERNAME -ErrorAction SilentlyContinue) -eq $null)
{
'[5] No Test account found' >> $log
}
else
{
'[5] Test account renamed to <local admin account> and set a secure password' >> $log
write-host 'Renaming Test account to <local admin account> and setting password'
Rename-LocalUser -Name "test" -NewName "<local admin account>"
Add-Type -AssemblyName 'System.Web'
$length = 25
$nonAlphaChars = 0
$Password = [System.Web.Security.Membership]::GeneratePassword($length, $nonAlphaChars)
"[5] <local admin account> Password: $Password" >> $log
$secure = ConvertTo-SecureString $Password -AsPlainText -Force
Set-LocalUser -name "<local admin account>" -Password $secure
}
Start-Sleep -s 2
#check if <local admin account> account is active
$USERNAME = "<local admin account>"
if((Get-LocalUser $USERNAME -ErrorAction SilentlyContinue) -eq $null)
{
'[5] No <local admin account> account found' >> $log
}
else
{
'[5] <local admin account> account has been activated' >> $log
}
}
catch {
'[5] <ERROR> failed to rename test account' >> $log
}
# [6] Installing software
'[6] Installing software' >> $log
'[INFO] there are 3 entries:' >> $log
'[INFO] 1) already installed: program was checked and already on the system, install skipped and moved to next program' >> $log
'[INFO] 2) has been installed: installer has been activated, program should be installed' >> $log
'[INFO] 3) failed to install: there was an error running the check or installer.' >> $log
### 1.Teamviewer
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 6%' -PercentComplete 6 -CurrentOperation 'Teamviewer'
$software = "Teamviewer";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
$installed.displayname
if ($installed.displayName -match $software)
{
Write-Host 'Teamviewer is already installed'
'[6] 1.Teamviewer is already installed' >> $log
}
else
{
Write-Host 'installing Teamviewer, click yes to install'
\\<servername>\Software\General\software\<software folder>\TeamViewer_Setup.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 1.Teamviewer has been installed' >> $log
}
}
catch {
'[6] <ERROR> 1.Teamviewer failed to install' >> $log
}
###
### 2.7zip
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 12%' -PercentComplete 12 -CurrentOperation '7zip'
$software = "7-zip";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 2.7zip is already installed' >> $log
}
else
{
Write-Host 'installing 7zip, no interaction needed'
\\<servername>\Software\General\software\<software folder>\7z.msi /qb
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 2.7zip has been installed' >> $log
}
}
catch {
'[6] <ERROR> 2.7zip failed to install' >> $log
}
###
### 3.Chrome
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 18%' -PercentComplete 18 -CurrentOperation 'Chrome'
$software = "chrome";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 3.Chrome is already installed' >> $log
}
else
{
Write-Host 'installing Google Chrome, no interaction needed'
\\<servername>\Software\General\software\<software folder>\chrome.exe /silent /install
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 3.Chrome has been installed' >> $log
}
}
catch {
'[6] <ERROR> 3.Chrome failed to install' >> $log
}
###
### 4.CutePDF converter (ghostscript)
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 24%' -PercentComplete 24 -CurrentOperation 'CutePDF converter'
$software = "ghost";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 4.CutePDF converter (ghostscript) is already installed' >> $log
}
else
{
Write-Host 'installing Converter (PDFwriter, ghostscript)'
\\<servername>\Software\General\software\<software folder>\converter.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 4.CutePDF converter (ghostscript) has been installed' >> $log
}
}
catch {
'[6] <ERROR> 4.CutePDF converter (ghostscript) failed to install' >> $log
}
###
### 5.CutePDF
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 30%' -PercentComplete 30 -CurrentOperation 'CutePDF'
$software = "cutepdf";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 5.CutePDF is already installed' >> $log
}
else
{
Write-Host 'installing CutePDFwriter'
\\<servername>\Software\General\software\<software folder>\CuteWriter.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 5.CutePDF has been installed' >> $log
}
}
catch {
'[6] <ERROR> 5.CutePDF failed to install' >> $log
}
###
### 6.HP Support Assistant
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 36%' -PercentComplete 48 -CurrentOperation 'HP Support Assistant'
$fileToCheck = "c:\SWSetup\sp111562\setup.exe"
if (Test-Path $fileToCheck -PathType leaf) {
'[6] 6.HP Support Assistant is already installed' >> $log
}
else
{
Write-Host 'Installing HP Support Assistant'
\\<servername>\Software\General\software\"<software folder>\sp111562.exe"
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 6.HP Support Assistant has been installed' >> $log
}
}
catch {
'[6] <ERROR> 6.HP Support Assistant failed to install' >> $log
}
###
### 7.Adobe Acrobat Reader
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 42%' -PercentComplete 42 -CurrentOperation 'Adobe Acrobat Reader'
$software = "adobe acrobat";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 7.Adobe Acrobat Reader is already installed' >> $log
}
else
{
Write-Host 'installing Acrobat Reader, press button when installed'
copy-item \\<servername>\Software\General\software\<software folder>\readerdc_en_xa_crd_install1.exe -destination \\<servername>\Software\General\software\<software folder>\readerdc_en_xa_crd_install.exe
\\<servername>\Software\General\software\<software folder>\readerdc_en_xa_crd_install.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 7.Adobe Acrobat Reader has been installed' >> $log
}
}
catch {
'[6] <ERROR> 7.Adobe Acrobat Reader failed to install' >> $log
}
###
### 8.monitoring agent, don't forget to activate anti-virus after device import in monitoring system
### installer changes every month, so check date.
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 48%' -PercentComplete 48 -CurrentOperation 'monitoring agent'
$software = "agent";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 8.monitoring agent is already installed' >> $log
}else{
Write-Host 'installing monitoring agent, press button when installed'
\\<servername>\Software\General\software\<software folder>\147WindowsAgentSetup_VALID_UNTIL_2021_06_10.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 8.monitoring agent has been installed' >> $log
}
}
catch {
'[6] <ERROR> 8.monitoring agent failed to install' >> $log
}
###
### 9.Greenshot
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 54%' -PercentComplete 54 -CurrentOperation 'Greenshot'
$software = "Greenshot";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 9.Greenshot is already installed' >> $log
}else{
Write-Host 'installing Greenshot, press button when installed'
\\<servername>\Software\General\software\<software folder>\Greenshot.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 9.Greenshot has been installed' >> $log
}
}
catch {
'[6] <ERROR> 9.Greenshot failed to install' >> $log
}
###
### 10.Forticlient
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 60%' -PercentComplete 60 -CurrentOperation 'Forticlient'
$software = "Forticlient";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 10.Forticlient is already installed' >> $log
}else{
Write-Host 'installing Forticlient, press button when installed'
\\<servername>\Software\General\software\<software folder>\Forticlient.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 10.Forticlient has been installed' >> $log
}
}
catch {
'[6] <ERROR> 10.Forticlient failed to install' >> $log
}
###
### 11.Office
### Check removes the office apps and installs the downloadable office pack, there have been some issues with the app version.
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 66%' -PercentComplete 66 -CurrentOperation 'Office'
#Delete Microsoft Office desktop app if present
$officecheck = Get-AppxPackage -Name Microsoft.Office.Desktop
if ($officecheck -eq $null)
{
'[6] 11.No Office desktop apps present' >> $log
}
else
{
write-host 'office desktop apps will be removed'
(Get-AppxPackage -Name Microsoft.Office.Desktop).Dependencies | Remove-AppxPackage
Write-Host 'continue after removal has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 11.Office desktop apps have been removed' >> $log
}
$software = "Office";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 11.Office is already installed' >> $log
}else{
Write-Host 'installing Office, press button when installed'
\\<servername>\Software\General\software\<software folder>\ProPlusRetail\Office\Setup64.exe
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
'[6] 11.Office has been installed' >> $log
}
}
catch {
'[6] <ERROR> 11.Office failed to install' >> $log
}
###
### 12.<company software1>
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 72%' -PercentComplete 72 -CurrentOperation '<company software1>'
$software = "<company software1>";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 12.<company software1> is already installed' >> $log
}else{
Write-Host 'installing <company software1>, press button when installed'
\\SATURNUS\<company software1>$\CLIENT\"<company software1> QMS 5.0 Setup.exe" /silent
'[6] 12.<company software1> has been installed' >> $log
Write-Host 'continue after install has finished';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
}
}
catch {
'[6] <ERROR> 12.<company software1> failed to install' >> $log
}
###
### 13.<company software1> addons
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 78%' -PercentComplete 78 -CurrentOperation '<company software1> addons'
$fileToCheck = 'C:\Program Files (x86)\<company software1> Software\unins000.dat'
if (Test-Path $fileToCheck -PathType leaf)
{
'[6] 13.<company software1> addons are already installed' >> $log
}
else
{
write-host '<company software1> Addons will be installed'
\\SATURNUS\<company software1>$\CLIENT\"<company software1> QMS 5.0 Addons.exe" /silent
'[6] 13.<company software1> addons are being installed' >> $log
Write-Host 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
}
}
catch {
'[6] <ERROR> 13.<company software1> addons failed to install' >> $log
}
###
### 14.<company software2>
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 84%' -PercentComplete 84 -CurrentOperation '<company software2>'
$software = "<company software2>";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 14.<company software2> is already installed' >> $log
}else{
Write-Host 'installing <company software2>, press button when installed'
\\<servername>\Software\General\software\"4.<company software2>.exe" /silent
'[6] 14.<company software2> has been installed' >> $log
Write-Host 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
}
}
catch {
'[6] <ERROR> 14.<company software2> failed to install' >> $log
}
###
### 15.<company software3>
try {
Write-Progress -Activity '<company> install script 48%' -Status 'Installing software 90%' -PercentComplete 90 -CurrentOperation '<company software3>'
$software = "rf";
$installed = (Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -Match $software })
if ($installed.displayName -match $software) {
'[6] 15.<company software3> is already installed' >> $log
}else{
Write-Host 'installing <company software3>, press button when installed'
\\<servername>\Software\General\<company>\"<company software3> 3.0.5\setup.exe" /quiet
'[6] 15.<company software3> has been installed' >> $log
Write-Host 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
}
Write-Progress -Activity 'Installing software' -Status 'Finished' -PercentComplete 100 -CurrentOperation InnerLoop
}
catch {
'[6] <ERROR> 15.<company software3> failed to install' >> $log
}
###
# [7] Create shortcuts
try{
Write-Progress -Activity '<company> install script 56%' -Status 'Creating shortcuts' -PercentComplete 56
$linkscreated = 0
$fileToCheck = 'C:\Users\Public\Desktop\<company software4> 2009 EN.lnk'
if (Test-Path $fileToCheck -PathType leaf)
{
'[7] <company software4> EN File already exists' >> $log
}
else
{
'[7] <company software4> EN File does not exist and will be added' >> $log
copy-item \\<servername>\Software\General\software\<software folder>\"<company software4> 2009 EN.lnk" -destination C:\Users\Public\Desktop\"<company software4> 2009 EN.lnk"
$linkscreated += 1
}
#<company software4> Dutch
$fileToCheck = 'C:\Users\Public\Desktop\<company software4> 2009 NL.lnk'
if (Test-Path $fileToCheck -PathType leaf)
{
'[7] <company software4> NL File already exists' >> $log
}
else
{
'[7] <company software4> NL File does not exist and will be added' >> $log
copy-item \\<servername>\Software\General\software\<software folder>\"<company software4> 2009 NL.lnk" -destination C:\Users\Public\Desktop\"<company software4> 2009 NL.lnk"
$linkscreated += 1
}
#<company software4> Test
$fileToCheck = 'C:\Users\Public\Desktop\<company software4> TEST 2009 EN.lnk'
if (Test-Path $fileToCheck -PathType leaf)
{
'[7] <company software4> Test EN File already exists' >> $log
}
else
{
'[7] <company software4> Test EN File does not exist and will be added' >> $log
copy-item \\<servername>\Software\General\software\"<software folder>\<company software4> TEST 2009 EN.lnk" -destination C:\Users\Public\Desktop\"<company software4> TEST 2009 EN.lnk"
$linkscreated += 1
}
#show how many links where created
if ($linkscreated -eq 1)
{
write-host '1 link has been added to the desktop'
'[7] 1 link has been added to the desktop' >> $log
}
else{
write-host "$linkscreated links have been added to the desktop"
"[7] $linkscreated links have been added to the desktop" >> $log
}
}
catch {
'[7] <ERROR> There was a problem creating shortcuts for <company software4>' >> $log
}
try{
$fileToCheck = 'c:\users\public\desktop\<company> Tijdsregistratie.lnk'
if (Test-Path $fileToCheck -PathType leaf)
{
'[7] Time registration already exists' >> $log
}
else
{
"Time registration does not exist and will be added"
'[7] Creating Time registration shortcut' >> $log
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("c:\users\public\desktop\<company> Tijdsregistratie.lnk")
$Shortcut.TargetPath = "<url to time registration>"
$shortcut.IconLocation = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$Shortcut.Save()
}
}
catch {
'[7] <ERROR> Time registration shortcut failed to create' >> $log
}
# [8] Add KLEUR and S&M printers
try {
Write-Progress -Activity '<company> install script 64%' -Status 'Adding printers' -PercentComplete 64
Add-Printer -ConnectionName \\<printserver>\kleur
Add-Printer -ConnectionName \\<printserver>\"s&m"
'[8] Added printers KLEUR and S&M' >>$log
}
catch {
'[8] <ERROR> Failed to add printers KLEUR and S&M' >>$log
}
# [9] system settings LUA/file and printer sharing
try {
Write-Progress -Activity '<company> install script 72%' -Status 'Checking system settings' -PercentComplete 72
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
'[9] Disabled user account control (LUA)' >>$log
}
catch {
'[9] <ERROR> Failed to disable user account control (LUA)' >>$log
}
try {
Set-NetFirewallRule -DisplayGroup "File And Printer Sharing" -Enabled True
'[9] Enabled printer and file sharing' >>$log
}
catch {
'[9] <ERROR> Failed to enable printer and file sharing' >>$log
}
try {
Set-NetFirewallRule -DisplayGroup "Bestands- en printerdeling" -Enabled True
'[9] Enabled printer and file sharing' >>$log
}
catch {
'[9] <ERROR> Failed to enable printer and file sharing' >>$log
}
# [10] import teamviewer reg key to set password.
try {
Write-Progress -Activity '<company> install script 80%' -Status 'Import Teamviewer settings' -PercentComplete 80
net stop teamviewer
reg import \\<servername>\Software\General\software\<software folder>\teamviewer.reg
net start teamviewer
$tvID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\TeamViewer" -Name ClientID).ClientID
"[10] Teamviewer ID: $tvID" >> $log
"[10] pw = <teamviwer pw>" >> $log
'[10] imported teamviewer registry file' >>$log
}
catch {
'[10] <ERROR> failed to import teamviewer registry file' >>$log
}
# [11] Pinning apps to taskbar
try {
Write-Progress -Activity '<company> install script 88%' -Status 'Pinning programs to taskbar' -PercentComplete 88
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Google\Chrome\Application\chrome.exe" c:5386
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Fortinet\FortiClient\Forticlient.exe" c:5386
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Microsoft Office\root\Office16\WINWORD.exe" c:5386
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.exe" c:5386
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Microsoft Office\root\Office16\outlook.exe" c:5386
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Microsoft Office\root\Office16\onenote.exe" c:5386
\\<servername>\Software\General\scripts\syspin "C:\Program Files\Microsoft Office\root\Office16\excel.exe" c:5386
'[11] Added programs to taskbar' >>$log
}
catch {
'[11] <ERROR> failed to add programs to taskbar' >>$log
}
# [12] Removing clutter +restart explorer.exe
try {
Write-Progress -Activity '<company> install script 96%' -Status 'Removing clutter' -PercentComplete 96
#remove searchbox + taskview clutter from taskbar
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Search" /V SearchboxTaskbarMode /T REG_DWORD /D 0 /F
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MultiTaskingView\AllUpView" /V Enabled /F
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V ShowTaskViewButton /T REG_DWORD /D 0 /F
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V ShowCortanaButton /T REG_DWORD /D 0 /F
# current user remove searchbox + taskview clutter from taskbar
REG ADD "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Search" /V SearchboxTaskbarMode /T REG_DWORD /D 0 /F
REG DELETE "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\MultiTaskingView\AllUpView" /V Enabled /F
REG ADD "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V ShowTaskViewButton /T REG_DWORD /D 0 /F
REG ADD "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V ShowCortanaButton /T REG_DWORD /D 0 /F
'[12] Removed the searchbar and taskview button' >> $log
#remove edge, store and mail clutter from taskbar
$appname = 'Microsoft Edge'
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true}
$appname = 'Microsoft Store'
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true}
$appname = 'Mail'
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true}
'[12] Cleared the taskbar' >> $log
#Remove cluttershortcuts
Remove-Item 'C:\Users\*\Desktop\<company software1>*lnk' -Force
Remove-Item 'C:\Users\*\Desktop\Microsoft*lnk' -Force
Remove-Item 'C:\Users\*\Desktop\rf*lnk' -Force
'[12] Cleared the shortcuts from desktop' >> $log
#restart explorer
taskkill /f /im explorer.exe
start explorer.exe
Write-Progress -Activity '<company> install script 100%' -Status 'Finished' -PercentComplete 100
}
catch {
'[12] <ERROR> Failed to remove the clutter' >> $log
}

Add comment

Comments

There are no comments yet.