Skip to content

Instantly share code, notes, and snippets.

@mwrock
Last active March 27, 2017 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwrock/0c4203ddc67e0192bdf2b95c7ff34192 to your computer and use it in GitHub Desktop.
Save mwrock/0c4203ddc67e0192bdf2b95c7ff34192 to your computer and use it in GitHub Desktop.
$ErrorActionPreference = "Stop"
. a:\Test-Command.ps1
Write-BoxstarterMessage "Enabling RemoteDesktop"
Enable-RemoteDesktop
Write-BoxstarterMessage "Setting PowerShell Policy to RemoteSigned"
Update-ExecutionPolicy -Policy RemoteSigned
if (Test-Command -cmdname 'Uninstall-WindowsFeature') {
Write-BoxstarterMessage "Removing unused features..."
Remove-WindowsFeature -Name 'Powershell-ISE'
}
Write-BoxstarterMessage "Setting Explorer Options"
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Write-BoxstarterMessage "copying & installing Chocolatey Packages"
Install-BoxstarterPackage -PackageName "A:\install.txt" -Credential $cred
Write-BoxstarterMessage "Removing page file"
$pageFileMemoryKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"
Set-ItemProperty -Path $pageFileMemoryKey -Name PagingFiles -Value ""
Write-BoxstarterMessage "Setting up winrm"
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
$enableArgs=@{Force=$true}
try {
$command=Get-Command Enable-PSRemoting
if($command.Parameters.Keys -contains "skipnetworkprofilecheck"){
$enableArgs.skipnetworkprofilecheck=$true
}
}
catch {
$global:error.RemoveAt(0)
}
Enable-PSRemoting @enableArgs
Enable-WSManCredSSP -Force -Role Server
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/client/auth '@{Basic="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
Write-BoxstarterMessage "restarting winrm"
net stop winrm
sc.exe config winrm start=auto
net start winrm
Write-BoxstarterMessage "winrm setup complete"
Write-BoxstarterMessage "Initial setup complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment