Last active
April 22, 2019 22:26
-
-
Save jlucktay/16bb166a98111733eb66 to your computer and use it in GitHub Desktop.
Boxstarter script for new machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Function definition, needed for a few installers that don't create their own desktop shortcuts. | |
# Puts the shortcut on the Public Desktop for everyone to use. | |
function Create-DesktopShortcut { | |
[CmdletBinding()] Param( | |
[Parameter(Mandatory=$True)] [string]$shortcutName, | |
[Parameter(Mandatory=$True)] [string]$targetPath | |
) | |
$objShell = New-Object -ComObject WScript.Shell | |
$objShortcut = $objShell.CreateShortcut($env:HOMEDRIVE + "\Users\Public\Desktop\" + $shortcutName + ".lnk") | |
$objShortcut.TargetPath = $targetPath | |
$objShortcut.Save() | |
Remove-Variable objShortcut | |
[Runtime.Interopservices.Marshal]::ReleaseComObject($objShell) | |
Remove-Variable objShell | |
} | |
# | |
# Check if we're on a domain, and exit if not | |
If (!(Get-CimInstance -Class Win32_ComputerSystem).PartOfDomain) { | |
Write-Host -ForegroundColor Red "This machine is not part of a domain. Please take care of that first, and then run this script again." | |
exit | |
} | |
# | |
# Figure out whether this is 32 or 64 bit, to put the proper 'Program Files' path into $programFiles for later use | |
If ((Get-CimInstance -Class Win32_Processor).AddressWidth -eq 64) {$programFiles = ${env:ProgramFiles(x86)}} Else {$programFiles = $env:ProgramFiles} | |
# | |
# Fix up some Windows and Powershell things | |
Set-CornerNavigationOptions -EnableUsePowerShellOnWinX | |
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart -EnableShowAppsViewOnStartScreen -EnableSearchEverywhereInAppsView | |
Set-WindowsExplorerOptions -EnableShowFileExtensions -EnableShowHiddenFilesFoldersDrives | |
Enable-PSRemoting -Force | |
Enable-RemoteDesktop | |
Update-ExecutionPolicy RemoteSigned | |
# | |
# Set up an all users/all hosts Powershell profile | |
Write-Output '$console = $host.UI.RawUI' | Out-File -FilePath $profile.AllUsersAllHosts | |
Write-Output '$buffer = $console.BufferSize' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$buffer.Width = 160' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$buffer.Height = 9999' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$console.BufferSize = $buffer' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$size = $console.WindowSize' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$size.Width = 160' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$size.Height = 80' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output '$console.WindowSize = $size' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
Write-Output 'Clear-Host' | Out-File -FilePath $profile.AllUsersAllHosts -Append | |
# | |
# Install these; all are one and done packages: | |
# .NET frameworks: 3.5 (includes 2.0 and 3.0) and 4.5.2 (includes 4.0, 4.5, and 4.5.1) | |
# Beyond Compare | |
# Chrome | |
# Java Development Kit (includes both 32-bit and 64-bit, defaults to using 64-bit) | |
# Nmap (network scanner, host/service discovery) | |
# VS2005 Visual C++ RunTime redistributable | |
# WinDirStat (disk space utility) | |
# IIS (via Windows features) | |
# Web Deploy | |
# Telnet client (via Windows features) | |
# Fiddler (built on .NET 4) | |
# Notepad++ | |
# Sysinternals entire suite of troubleshooting tools | |
chocolatey install DotNet3.5 | |
chocolatey install DotNet4.5.2 | |
chocolatey install beyondcompare | |
chocolatey install GoogleChrome | |
chocolatey install jdk8 -params "both=true" | |
chocolatey install nmap | |
chocolatey install vcredist2005 | |
chocolatey install windirstat | |
chocolatey install IIS-WebServerRole -source windowsfeatures | |
chocolatey install webdeploy | |
chocolatey install TelnetClient -source windowsfeatures | |
chocolatey install fiddler4 | |
Create-DesktopShortcut -shortcutName "Fiddler" -targetPath $($programFiles + "\Fiddler2\Fiddler.exe") | |
chocolatey install notepadplusplus.install | |
Create-DesktopShortcut -shortcutName "Notepad++" -targetPath $($programFiles + "\Notepad++\notepad++.exe") | |
chocolatey install sysinternals | |
Create-DesktopShortcut -shortcutName "Sysinternals" -targetPath "C:\Tools\Sysinternals" | |
# | |
# Check if Tortoise is installed, and if not, do the install, do a checkout of the Testing directory to C:\Testing\, and also set the config not to save any passwords | |
chocolatey list -localonly | ForEach-Object {If ($($_ -split " ")[0] -eq "tortoisesvn") {$bTortoiseInstalled = $true}} | |
If (!$bTortoiseInstalled) { | |
chocolatey install tortoisesvn | |
svn checkout http://ap21-source-01:8080/svn/live/Testing C:\Testing --username BASSDOM\JLTest --non-interactive | |
$FilePath = $env:APPDATA + "\Subversion\config" | |
(Get-Content($FilePath)) | ForEach-Object {$_ -replace '^# password-stores =$', ("password-stores =")} | Set-Content($Filepath) | |
(Get-Content($FilePath)) | ForEach-Object {$_ -replace '^# store-passwords = no$', ("store-passwords = no")} | Set-Content($Filepath) | |
$FilePath = $env:APPDATA + "\Subversion\servers" | |
(Get-Content($FilePath)) | ForEach-Object {$_ -replace '^# store-passwords = no$', ("store-passwords = no")} | Set-Content($Filepath) | |
(Get-Content($FilePath)) | ForEach-Object {$_ -replace '^# store-plaintext-passwords = no$', ("store-plaintext-passwords = no")} | Set-Content($Filepath) | |
} | |
# | |
# Install, configure, and start the Zabbix agent, to report back to the monitoring mothership | |
chocolatey list -localonly | ForEach-Object {If ($($_ -split " ")[0] -eq "zabbix-agent") {$bZabbixAgentInstalled = $true}} | |
If (!$bZabbixAgentInstalled) { | |
chocolatey install zabbix-agent | |
$FilePath = "C:\Program Files\Zabbix Agent\zabbix_agentd.conf" | |
Write-Output "LogFile=C:\zabbix_agentd.log" | Out-File -FilePath $FilePath -Append -Encoding ascii | |
Write-Output "LogFileSize=1" | Out-File -FilePath $FilePath -Append -Encoding ascii | |
Write-Output "Server=192.168.193.127" | Out-File -FilePath $FilePath -Append -Encoding ascii | |
Write-Output "Hostname=$([Net.Dns]::GetHostName())" | Out-File -FilePath $FilePath -Append -Encoding ascii | |
netsh advfirewall firewall add rule name=ZabbixAgent dir=in action=allow localport=10050 protocol=tcp | |
Start-Service -Name "Zabbix Agent" | |
} | |
# | |
# Tell Windows Update not to automatically reboot the machine whenever it sees fit (thanks for that, Microsoft) | |
Write-Host NoAutoRebootWithLoggedOnUsers registry key: | |
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoRebootWithLoggedOnUsers /t REG_DWORD /d 1 /f | |
# | |
# On Windows 8 (and later) tell Windows not to sleep/lock due to inactivity | |
If (([Environment]::OSVersion.Version.Major -eq 6 -and [Environment]::OSVersion.Version.Minor -ge 2) -or ([Environment]::OSVersion.Version.Major -ge 7)) { | |
Write-Host InactivityTimeoutSecs registry key: | |
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v InactivityTimeoutSecs /t REG_DWORD /d 0 /f | |
} | |
# | |
# Create some commonly used directories under C:\ | |
If (!(Test-Path -Path C:\Jenkins)) {New-Item -ItemType directory -Path C:\Jenkins} | |
If (!(Test-Path -Path C:\Temp)) {New-Item -ItemType directory -Path C:\Temp} | |
If (!(Test-Path -Path "C:\TestComplete Excel Logs")) {New-Item -ItemType directory -Path "C:\TestComplete Excel Logs"} | |
If (!(Test-Path -Path "C:\TestComplete HTML Logs")) {New-Item -ItemType directory -Path "C:\TestComplete HTML Logs"} | |
# | |
# Allow HTTP (IIS serving web pages) and SMB (network shares) through the firewall | |
Write-Host HTTP firewall rule: | |
netsh advfirewall firewall add rule name=HTTP dir=in action=allow localport=80 protocol=tcp | |
Write-Host SMB firewall rule: | |
netsh advfirewall firewall add rule name=SMB dir=in action=allow localport=445 protocol=tcp | |
# | |
# Share "C:\TestComplete Excel Logs" as a network share named "CI" | |
Write-Host CI network share: | |
net share CI="C:\TestComplete Excel Logs" | |
# | |
# Share "C:\TestComplete HTML Logs" as a virtual directory via IIS | |
Write-Host WebAdministration module import: | |
Import-Module WebAdministration | |
Write-Host IIS virtual directory: | |
New-WebVirtualDirectory -Site 'Default Web Site' -Name 'TestComplete HTML Logs' -PhysicalPath "C:\TestComplete HTML Logs" -Force | |
# | |
# Get Powershell help up to date | |
Update-Help | |
# | |
# Open some network directories with some more things that need to be installed manually | |
Invoke-Item "\\file2008\DriveD\Ap21 Release Installation\AP21 Client" | |
Invoke-Item "\\file2008\Apparel21\2014.2\POSClient" | |
Invoke-Item "\\oracle\Software\SmartBear" | |
# | |
# Clean up Boxstarter autologin | |
# Note: keep this last in the script | |
### | |
###$winLogonKey="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" | |
###Remove-ItemProperty -Path $winLogonKey -Name "DefaultUserName" -ErrorAction SilentlyContinue | |
###Remove-ItemProperty -Path $winLogonKey -Name "DefaultDomainName" -ErrorAction SilentlyContinue | |
###Remove-ItemProperty -Path $winLogonKey -Name "DefaultPassword" -ErrorAction SilentlyContinue | |
###Remove-ItemProperty -Path $winLogonKey -Name "AutoAdminLogon" -ErrorAction SilentlyContinue | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment