Skip to content

Instantly share code, notes, and snippets.

View phwelo's full-sized avatar
🌈

Daniel Agans phwelo

🌈
View GitHub Profile
@phwelo
phwelo / runlist_conslidator.ps1
Last active February 5, 2018 19:12
[Get Chef Runlist] Get a Chef runlist #Chef #Powershell
param(
[string]$nodename = 'nodename'
)
$knife_show = knife node show $nodename
[string]$result = ($knife_show | select-string -pattern 'Run List:')
$runlist = $result.substring(13)
return $runlist
loops through users passing vaqriable usr, which is hash of user properties
sudo usr[:id] do
user usr[:id]
commands ['/etc/init.d/syslog-ng *','/bin/systemctl * syslog-ng.service', '/bin/systemctl * syslog-ng']
nopasswd true
end
@phwelo
phwelo / WaitForBoot.ps1
Last active February 5, 2018 19:12
[Wait for IP Address] Wait for VM to come up (evaluate by IP address) PowerCLI #Powershell #VMWare
function WaitForBoot($VM) {
$TimeOut = New-TimeSpan -Minutes 2
$StopWatch = [diagnostics.stopwatch]::StartNew()
while ($StopWatch.elapsed -lt $TimeOut) {
$VM = Get-VM -name $VM
if ($VM.Guest.IPAddress) {
write-host 'Cool'
return
}
for ($i=0; $i -le 4; $i++) {
@phwelo
phwelo / ConfirmShutdown.ps1
Last active February 5, 2018 19:09
[ConfirmShutdown] Powershell function that manually waits for machine to power off. #powershell
function ConfirmShutdown($VM) {
$TimeOut = New-TimeSpan -Minutes 5
$StopWatch = [diagnostics.stopwatch]::StartNew()
while ($StopWatch.elapsed -lt $TimeOut) {
$VM = Get-VM -name $VM
if ($VM.PowerState -eq 'PoweredOff') {
write-host 'Cool'
return
}
for ($i=0; $i -le 4; $i++) {
@phwelo
phwelo / bump.ps1
Last active February 5, 2018 19:07
[Bump] Bump a Chef cookbook version using powershell #powershell #chef
function bump {
function version-isolate{
[array]$metadata = Get-Content .\metadata.rb
[string]$verline = $metadata|where-object{$_ -like "*version*"}
$version = $verline.split("'")[1]
return $version
}
function version-increase{
$version = version-isolate
$version_array = $version.split(".")
@phwelo
phwelo / build_connectionstring.ps1
Last active February 5, 2018 19:08
[Connection String Builder] Builds a connection string based on parameters #Powershell #SQL
function New-ConnectionString($Server,$Catalog,[bool]$PersistSecurity,$User,$Password) {
$ConnectionString = "Data Source=$Server;Initial Catalog=$Catalog;Persist Security Info=$([string]$PersistSecurity);User ID=$User;Password=$Password"
return $ConnectionString
}
@phwelo
phwelo / setup_winrm.ps1
Last active February 6, 2018 02:03 — forked from mitchellh/setup_winrm.txt
[Packer WinRM config] Userdata for packer to config winrm in a sane way #Powershell #WinRM #Packer
<powershell>
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
@phwelo
phwelo / AllComputers.ps1
Last active April 23, 2018 20:11
Loop through all computers in an active directory domain
$ADDomain = 'domain.local'
if((Get-ADDomain -Current LocalComputer) -like "$ADDomain"){
Write-Host "Credentials will be inherited from logged in session"
$ADDomain_Obj = Get-ADDomain $ADDomain
} else {
$Credential= Get-Credential -Message "Enter credentials for $ADDomain"
$ADDomain_Obj = Get-ADDomain $ADDomain -Credential $Credential
}
@phwelo
phwelo / nginx.conf
Last active February 5, 2018 19:03
Basic nginx configuration #nginx #configuration
worker_processes 1;
error_log /dev/stdout info;
events {
worker_connections 1024;
}
http {
# Hide nginx version information.
@phwelo
phwelo / hack.css
Last active February 6, 2018 02:11
[Plug.io CSS hack] CSS hack for custom background on plug.dj #css #plug.dj
.room-background {
background: url('https://janetgranger.files.wordpress.com/2011/10/alice-blue-roomset.jpg')!important;
background-size: cover!important;
background-position: center!important;
background-repeat: no-repeat!important;
}