Last active
August 28, 2016 02:01
-
-
Save devhawk/d5e9d66238717bab0e23 to your computer and use it in GitHub Desktop.
Boxstarter Configuration
This file contains hidden or 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
# boxstarter script for basic machine configuration | |
# basic Windows configuration stuff | |
Enable-RemoteDesktop | |
Update-ExecutionPolicy RemoteSigned | |
Set-WindowsExplorerOptions -EnableShowFileExtensions | |
Install-WindowsUpdate -Critical | |
# download profile script from GitHub Gist | |
Invoke-WebRequest https://api.github.com/gists/d5e9d66238717bab0e23 | ConvertFrom-Json | %{ | |
New-Item (split-path $PROFILE.CurrentUserAllHosts) -Force -Type directory | Out-Null; | |
Set-Content $profile.CurrentUserAllHosts $_.files.'profile.ps1'.content | |
} | |
# install notepad2-mod and 7zip | |
cinst notepad2-mod | |
cinst 7zip.install | |
# add "Open with Notepad2" to all file context menus | |
# note I'm using reg.exe here because PS has issues with paths that contain '*' | |
reg add HKCR\*\shell\Notepad2 /d "Open with Notepad2" /f | |
reg add HKCR\*\shell\Notepad2\command /d 'notepad.exe \"%1\"' /f | |
#set the default console settings | |
Set-ItemProperty -path HKCU:\Console -name QuickEdit -value 1 | |
Set-ItemProperty -path HKCU:\Console -name FaceName -value Consolas | |
Set-ItemProperty -path HKCU:\Console -name FontFamily -value 54 | |
Set-ItemProperty -path HKCU:\Console -name FontSize -value 0x100000 | |
Set-ItemProperty -path HKCU:\Console -name ScreenBufferSize 0xbb80078 #ScreenBufferSize 120 w x 3000 h | |
Set-ItemProperty -path HKCU:\Console -name WindowSize 0x280078 #WindowSize 120 w x 40 h | |
# delete all the exe specific console settings | |
dir hkcu:\console | %{del -path $_.pspath} | |
# remove console property settings from start menu shortcuts | |
# following code adapted from http://blog.sourcewarp.com/2010/05/windows-powershell-shortcut-ishelllink.html | |
# TODO: contribute this code as a PS script back to BoxStarter | |
$shelllinkAPI = @" | |
using System; | |
using System.Runtime.InteropServices; | |
namespace DevHawk | |
{ | |
[ComImport(), | |
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | |
Guid("0000010B-0000-0000-C000-000000000046")] | |
public interface IPersistFile | |
{ | |
#region Methods inherited from IPersist | |
void GetClassID(out Guid pClassID); | |
#endregion | |
[PreserveSig()] int IsDirty(); | |
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, int dwMode); | |
void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember); | |
void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName); | |
void GetCurFile(out IntPtr ppszFileName); | |
} | |
[ComImport(), | |
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), | |
Guid("45E2b4AE-B1C3-11D0-B92F-00A0C90312E1")] | |
public interface IShellLinkDataList | |
{ | |
void AddDataBlock(IntPtr pDataBlock); | |
void CopyDataBlock(uint dwSig, out IntPtr ppDataBlock); | |
void RemoveDataBlock(uint dwSig); | |
void GetFlags(out int dwFlags); | |
void SetFlags(uint dwFlags); | |
} | |
public static class ShellLink | |
{ | |
public static void Load(object shellLink, string fileName, int mode) | |
{ | |
((IPersistFile)shellLink).Load(fileName, mode); | |
} | |
public static void RemoveDataBlock(object shellLink, uint dwSig) | |
{ | |
((IShellLinkDataList)shellLink).RemoveDataBlock(dwSig); | |
} | |
public static void Save(object shellLink) | |
{ | |
((IPersistFile)shellLink).Save(null, true); | |
} | |
public const uint CONSOLE_PROPS = 0xA0000002; | |
} | |
} | |
"@ | |
add-type -TypeDefinition $shelllinkAPI | |
dir "C:\ProgramData\Microsoft\Windows\Start Menu\" -Recurse -Include *.lnk | %{ | |
$name = $_.Name | |
Try | |
{ | |
$shellLink = new-object -ComObject lnkfile | |
[DevHawk.ShellLink]::Load($shellLink, $_.FullName, 2); | |
[DevHawk.ShellLink]::RemoveDataBlock($shellLink, [DevHawk.ShellLink]::CONSOLE_PROPS); | |
[DevHawk.ShellLink]::Save($shellLink); | |
} | |
Catch [System.Exception] | |
{ | |
write-host " couldn't update $name" | |
} | |
} |
This file contains hidden or 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
cinst git.install | |
cinst git-credential-winstore | |
cinst gitextensions | |
# choco install nodejs.install | |
# choco install visualstudiocommunity2013 -InstallArguments "/Features:'WebTools SQL'" | |
set-alias gitexe "C:\Program Files (x86)\Git\cmd\git.exe" | |
gitexe config --global user.name "Harry Pierson" | |
gitexe config --global user.email "[email protected]" | |
gitexe config --global alias.st status | |
gitexe config --global alias.br branch | |
gitexe config --global alias.co checkout | |
gitexe config --global alias.ci commit |
This file contains hidden or 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 Run-Boxstarter-From-Gist($gistId, $fileName) { | |
Invoke-WebRequest "https://api.github.com/gists/$gistId" -UseBasicParsing | ConvertFrom-Json | %{ | |
$local:boxstarterUrl = "http://boxstarter.org/package/url?$($_.files.$fileName.raw_url)" | |
& 'C:\Program Files\Internet Explorer\iexplore.exe' -new $local:boxstarterUrl | |
} | |
} | |
Run-Boxstarter-From-Gist d5e9d66238717bab0e23 basicconfig.ps1 | |
Run-Boxstarter-From-Gist d5e9d66238717bab0e23 devcconfig.ps1 |
This file contains hidden or 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
#------------------------------------------------------------------------------ | |
#set the screen color based on the user role | |
if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
$host.UI.RawUI.Backgroundcolor="DarkRed" | |
$host.UI.RawUI.WindowTitle = "PowerShell Admin Console" | |
} else { | |
$host.UI.RawUI.Backgroundcolor="Black" | |
$host.UI.RawUI.WindowTitle = "PowerShell User Console" | |
} | |
$host.UI.RawUI.Foregroundcolor="White" | |
if ($env:PROCESSOR_ARCHITECTURE -eq "x86") { | |
$host.UI.RawUI.WindowTitle += " (x86)" | |
} else { | |
$host.UI.RawUI.WindowTitle += " (x64)" | |
} | |
clear-host | |
#------------------------------------------------------------------------------ | |
# Locate top level OneDrive path | |
$env:ONEDRIVEPATH = ,"~\OneDrive\" + (Get-WmiObject -Class Win32_LogicalDisk | | |
? {$_.DriveType -eq 3} | | |
% {$_.DeviceID} | | |
join-path -ChildPath "OneDrive") | | |
?{test-path $_} | | |
Select-object -first 1 | | |
Resolve-Path | | |
%{$_.path} | |
#------------------------------------------------------------------------------ | |
# add OneDrive\Scripts folder to path for access to scripts | |
function Append-Path([Parameter(Mandatory=$true)][string]$path) | |
{ | |
$path = Resolve-Path($path) | |
# convert the list of paths to an array, removing any empty paths | |
$local:paths = $env:path.split(';') | ? {![string]::IsNullOrWhiteSpace($_)} | |
if ($path -notin $local:paths) { | |
Set-Content Env:\Path (($local:paths + $path) -join ';') | |
} | |
} | |
Append-Path (join-path $env:ONEDRIVEPATH "Scripts") | |
Append-Path (Split-Path -parent $MyInvocation.MyCommand.Definition) | |
#------------------------------------------------------------------------------ | |
# override built in prompt function w/ prompt.ps1 | |
function global:prompt { | |
$locStackCount = (Get-Location -stack).count | |
Write-Host $executionContext.SessionState.Path.CurrentLocation.ProviderPath -foregroundcolor Cyan | |
if ($locStackCount -gt 0) { | |
write-host ("+" * $locStackCount) -NoNewLine -ForegroundColor Yellow | |
write-host " " -NoNewLine | |
} | |
write-host "PS>" -NoNewLine -ForegroundColor Green | |
return " " | |
} | |
#------------------------------------------------------------------------------ | |
#set some common aliases | |
set-alias n2 notepad.exe | |
set-alias vs devenv | |
set-alias su elevate-process.ps1 | |
set-alias gitex (join-path $env:ONEDRIVEPATH "Utilities\GitExtensions\GitExtensions.exe") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment