Skip to content

Instantly share code, notes, and snippets.

View hclpandv's full-sized avatar
🎯
Focusing

Vikas Pandey hclpandv

🎯
Focusing
View GitHub Profile
$TargetDisks = Get-WmiObject win32_LogicalDisk -Filter "DriveType=3" | Sort-Object -Property Size -Descending
if($TargetDisks.Count -gt 4) {
Write-Host "An Error. Exiting"
Exit
}
(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)} | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize
@hclpandv
hclpandv / wait_for_http_200.sh
Created April 25, 2019 05:51 — forked from rgl/wait_for_http_200.sh
Wait for an HTTP endpoint to return 200 OK with Bash and curl
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76
@hclpandv
hclpandv / ansible-github.yml
Created November 27, 2018 03:01 — forked from devynspencer/ansible-github.yml
Example playbook for cloning a private git repository with Ansible.
---
hosts: all
tasks:
- name: add github ssh key
copy: >
src=files/id_rsa.github
dest=/root/.ssh/id_rsa.github
owner=root
group=root
Function InvokeScript-FromGitHub ($github_script_raw_uri){
$github_script_raw_uri = "https://gist.githubusercontent.com/hclpandv/76739cc615f3eee0d4722243379d324f/raw/9573fa17aadee9f0b5fb71d38cccefde8b4a220b/CheckSumCalc.ps1"
$temp_script_file = "$pwd\temp.ps1"
Invoke-RestMethod -Uri $github_script_raw_uri -Method GET | Out-File $temp_script_file
& $temp_script_file
Remove-Item $temp_script_file -Force
}
function Invoke-RestApiCall(){
#This is function to be used in PS 2.0 version
param(
[string]$Uri ,
[string]$Method = "GET" ,
[int]$RequestTimeout=60000 , #Milliseconds
[string]$ContentType
)
[Net.HttpWebRequest] $request = [Net.WebRequest]::create($Uri)
@hclpandv
hclpandv / bash_script_template_v10.sh
Created March 5, 2018 15:20
Bash Script Template
#!/usr/bin/env bash
SCRIPT_VERSION=1.0
# Description : This is a script template which can be reused for any script to be deployed
# Date : 26/Feb/2018
# Contact : Vikas Pandey
DEBUG=false
[[ "${DEBUG}" == 'true' ]] && set -o errexit
@hclpandv
hclpandv / 1_WrtingCode_InputOutput.py
Last active December 29, 2017 07:01
Python Tutorial : Essentials
#!/usr/bin/python3
print("Hello World!")
user_name = input("Please Enter Your User Name: ")
print("User Name Entered is " + user_name)
@hclpandv
hclpandv / Save-XlsAsCSV.ps1
Created August 25, 2017 11:20
PowerShell Function Save-XlsAsCSV
Function Save-XlsAsCSV ($excelFile, $csvFile)
{
$E = New-Object -ComObject Excel.Application
$E.Visible = $false
$E.DisplayAlerts = $false
$wb = $E.Workbooks.Open($excelFile)
foreach ($ws in $wb.Worksheets)
{
$n = $excelFile + "_" + $ws.Name
$ws.SaveAs($csvFile, 6)
@hclpandv
hclpandv / RemoteServices.ps1
Created August 11, 2017 09:58
Services Report from
Function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
cd (Get-ScriptDirectory)
$Header = @"
<style>