Skip to content

Instantly share code, notes, and snippets.

View giseongeom's full-sized avatar
💭
I may be slow to respond.

GiSeong Eom giseongeom

💭
I may be slow to respond.
View GitHub Profile
@giseongeom
giseongeom / Notify-Slack.ps1
Last active April 15, 2018 04:39
Notification into slack (incoming webhook)
$slack_uri_default = 'https://hooks.slack.com/services/'
# Notification via Slack
function Notify-Slack()
{
param
(
[Parameter(Mandatory=$true)]
$text,
@giseongeom
giseongeom / Find-RecoveryEnabledService.ps1
Created April 6, 2018 01:43
Find a few windows services that has recovery action configured
$vmlist = Get-ADComputer -Filter "Name -like 'P*'" | Select-Object -ExpandProperty Name
foreach ($vm in $vmlist)
{
icm -ComputerName $vm -ScriptBlock {
$live_services = get-service live_*
foreach ($live_service in $live_services)
{
$check_result = (sc.exe qfailure $live_service | Select-String failure_actions).length
if ($check_result -gt 0) { Write-Host $env:COMPUTERNAME - $live_service.Name has recovery configured }
@giseongeom
giseongeom / Get-AzureRMVMNicIP.ps1
Last active March 28, 2018 02:57
Display AzureRM VMName and (Primary) Private IP
$allNIC = Get-AzureRmNetworkInterface
$allVM = get-azurermvm | Select-Object Name, ResourceGroupName, NetworkProfile
$targetVM = $allVM | Where-Object { ($_.Name -like "*proxy*") -or ($_.Name -like "*api*") }
# See https://blogs.technet.microsoft.com/rmilne/2016/11/15/how-to-get-azure-rm-vm-ip-addresses-using-powershell/
ForEach ($VMInfo in $targetVM) {
$VMName = $VMInfo.Name
$nic_id = $VMInfo.NetworkProfile.NetworkInterfaces[0].id
$nic_info = $allNIC | Where-Object { $_.id -match $nic_id }
$nic_private_ip = $nic_info.IpConfigurations.PrivateIpAddress
@giseongeom
giseongeom / Eject-USB.ps1
Last active January 23, 2018 13:05
Eject-USB
function MyEject-USB {
# See https://blogs.technet.microsoft.com/heyscriptingguy/2011/01/11/validate-powershell-parameters-before-running-the-script/
param
(
[Parameter(Mandatory = $true)]
[ValidatePattern("^[A-Za-z]$")]
$Drive
)
# See https://superuser.com/questions/1283149/remove-usb-device-from-commandline
@giseongeom
giseongeom / Remove-LegacyDataDogAgent.ps1
Last active December 9, 2017 09:33
Remove Datadog Agent for Windows prior to 5.12 forcefully
Stop-Service -Verbose -Force "DatadogAgent"
Start-Sleep 5
sc.exe delete DatadogAgent
Start-Sleep 5
Remove-Item -Recurse -Force 'C:\Program Files (x86)\Datadog\' 2>&1 | Out-Null
$ddlegacyregpath = (
Get-ChildItem HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
@giseongeom
giseongeom / upgrade-memcached.sh
Last active September 19, 2022 20:36
Upgrade-memcached-on-centos6
#!/usr/bin/env bash
# Download remi-release rpm
# See https://centos.pkgs.org/6/remi-x86_64/memcached-1.5.3-1.el6.remi.x86_64.rpm.html
curl -o /tmp/remi.rpm http://rpms.famillecollet.com/enterprise/6/remi/x86_64/remi-release-6.9-1.el6.remi.noarch.rpm
# Enable Remi repo (epel also enabled)
sudo yum localinstall -y /tmp/remi.rpm
# Remove previously-installed memcached 1.4
@giseongeom
giseongeom / example_packer_template.json
Last active March 2, 2024 22:24
packer template (sysprep-safe)
{
"variables": {
"client_id": "{{env `AZURE_CLIENT_ID`}}",
"client_secret": "{{env `AZURE_CLIENT_SECRET`}}",
"subscription_id": "{{env `AZURE_SUBSCRIPTION_ID`}}",
"tenant_id": "{{env `AZURE_TENANT_ID`}}",
"spn_object_id": "{{env `AZURE_SPN_OBJECT_ID`}}",
"resource_group": "{{env `AZURE_BUILD_RESOURCE_GROUP`}}",
"resource_location": "{{env `AZURE_BUILD_LOCATION`}}",
"storage_account": "{{env `AZURE_BUILD_STORAGE_ACCOUNT`}}",
@giseongeom
giseongeom / jdkextract.cmd
Last active March 23, 2017 08:35
jdkextract - Extract JDK files from oracle distribution without install
@echo off
SETLOCAL
IF #%1# == ## (
GOTO :usage
) ELSE (
GOTO :main
)
@giseongeom
giseongeom / list-alphanum.ps1
Created March 14, 2017 03:01
List alphabet + number as single string
$a=''
$b=''
[char[]]([char]'a'..[char]'z') | % { [string]$a+=$_ } ; $a
0..9 | % { [string]$b+=$_ } ; $b
$a + $b
@giseongeom
giseongeom / packer-0.8.6-aws-error.txt
Last active January 12, 2016 02:19
packer log when validating template fails (used with AWS seoul region / ap-northeast-2)
[x86_64-unknown-cygwin] giseong.eom@GISEONG-PC ~/home/Documents/packer-getting-started
$ PACKER_LOG=1 packer validate create-1st-custom-ami.json
2016/01/12 11:14:43 [INFO] Packer version: 0.8.6 f8f7b7a34c1be06058f5aca23a51247db12cdbc5+CHANGES
2016/01/12 11:14:43 Packer Target OS/Arch: windows amd64
2016/01/12 11:14:43 Built with Go Version: go1.5
2016/01/12 11:14:43 [DEBUG] Discovered plugin: amazon-chroot = C:\App\Vagrant\bin\packer-builder-amazon-chroot.exe
2016/01/12 11:14:43 [DEBUG] Discovered plugin: amazon-ebs = C:\App\Vagrant\bin\packer-builder-amazon-ebs.exe
2016/01/12 11:14:43 [DEBUG] Discovered plugin: amazon-instance = C:\App\Vagrant\bin\packer-builder-amazon-instance.exe
2016/01/12 11:14:43 [DEBUG] Discovered plugin: digitalocean = C:\App\Vagrant\bin\packer-builder-digitalocean.exe
2016/01/12 11:14:43 [DEBUG] Discovered plugin: docker = C:\App\Vagrant\bin\packer-builder-docker.exe