Skip to content

Instantly share code, notes, and snippets.

View kenpb's full-sized avatar

Kenneth P. Barquero kenpb

  • Cartago, Costa Rica
View GitHub Profile
@kenpb
kenpb / upgrade-windowserver-edition.ps1
Last active November 16, 2015 01:12
Upgrade from WS12R2 Eval to Standard
DISM /online /Set-Edition:ServerStandard /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula
@kenpb
kenpb / create-shortcuts.ps1
Created November 16, 2015 01:10
A simple script to create shortcuts with powershell
$root = "\\VBOXSRV\"
$folders = "common", "vagrant"
$nCOM = New-Object -ComObject WScript.Shell
$folders | ForEach-Object {
$shortcut = $nCOM.CreateShortcut("$Home\Desktop\" + $_ + " (VBOXSRV).lnk")
$shortcut.TargetPath = $root + $_
$shortcut.Save()
}
@kenpb
kenpb / elevator.ps1
Created November 17, 2015 00:57
A self elevating PowerShell script
# @source => http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/23/a-self-elevating-powershell-script.aspx
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
@kenpb
kenpb / disable-windows-firewall.ps1
Last active August 3, 2018 10:08
Disable windows stuff
# source: https://blogs.technet.microsoft.com/heyscriptingguy/2012/10/28/powertip-use-powershell-to-enable-the-windows-firewall/
# older Wins: netsh advfirewall set allprofiles state off
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
@kenpb
kenpb / Microsoft.PowerShell_profile.ps1
Created November 26, 2015 21:24
My powershell console profile preferences
$shell = $host.ui.RawUI
# Buffersize
$buffer = $shell.BufferSize
$buffer.width = 120
$buffer.height = 2000
$shell.BufferSize = $buffer
# WindowSize
$size = $shell.WindowSize
function Remove-LocalUserProfile {
<#
.SYNOPSIS
Removes a local user profile from the local or remote computer.
.DESCRIPTION
Removes a local user profile from the local or a remote computer by getting the Win32_UserProfile WMIObject, translating the SIDs to
usernames, and removing the profile if the result matches the specified username.
.PARAMETER ComputerName
Name of the computer you want to remove the user from.
.PARAMETER User
@kenpb
kenpb / Vagrantfile
Created February 10, 2016 07:25 — forked from leifg/Vagrantfile
Add a second disk to system using vagrant
file_to_disk = './tmp/large_disk.vdi'
Vagrant::Config.run do |config|
config.vm.box = 'base'
config.vm.customize ['createhd', '--filename', file_to_disk, '--size', 500 * 1024]
config.vm.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end
@kenpb
kenpb / Vagrantfile
Created February 10, 2016 08:02 — forked from phips/Vagrantfile
host1.vm.provider :vmware_fusion do |vmw|
vdiskmanager = '/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager'
dir = "#{ENV['PWD']}/.vagrant/additional-disks"
unless File.directory?( dir )
Dir.mkdir dir
end
file_to_disk = "#{dir}/hd2.vmdk"
unless File.exists?( file_to_disk )
`#{vdiskmanager} -c -s 10GB -a lsilogic -t 0 #{file_to_disk}`
end
@kenpb
kenpb / install-libsodium.sh
Created March 11, 2016 04:55 — forked from sarciszewski/install-libsodium.sh
Install libsodium-1.0.2 and PECL libsodium on Ubuntu 14.04
#!/usr/bin/env bash
PECLVER="0.1.1"
LIBSODIUMVER="1.0.2"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@kenpb
kenpb / install-ruby-gems.sh
Last active April 6, 2016 07:51 — forked from scmx/upgrade-install-ruby-2-1-2-ubuntu-12-04.md
Upgrade/Install ruby 2.2.2 #ubuntu #12.04 #14.04 for vagrant
# Reference http://stackoverflow.com/a/18490935/2037928
sudo apt-get update --fix-missing
# Install needed packages
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
# Download appropriate ruby version https://www.ruby-lang.org/en/downloads/
wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz