Skip to content

Instantly share code, notes, and snippets.

View praveenc's full-sized avatar
🎯
Focusing

Praveen Chamarthi praveenc

🎯
Focusing
  • United States
View GitHub Profile
# Encode string to base64
# =======================
$u="username"
$p="password"
$b64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($u+":"+$p))
# E.g. For use in Authorization Headers
@praveenc
praveenc / Ignore-SSLErrors.ps1
Last active September 25, 2017 14:42
REST query from a Self-Signed SSL Resource
#==========================================================
#To Ignore SSL Certificate Errors and Continue Use This
#==========================================================
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
Get-ChildItem "C:\test" -Force | ? {$_.mode -match "h"} | foreach {$_.Attributes = [System.IO.FileAttributes]::Normal}
Add-WindowsFeature "Net-Framework-Core"
Add-WindowsFeature "Web-Server","Web-Mgmt-Tools","Web-App-Dev","Web-Http-Redirect","Web-Asp-Net45"
# Create drop folders for builds
if(-not (Test-Path "c:\build_drop"))
{
mkdir "c:\build_drop" | Out-Null
}
# Create logs folder
Add-WindowsFeature "Web-Server","Web-Mgmt-Tools","Web-App-Dev","Web-Http-Redirect","Web-Asp-Net45"
# Create drop folders for builds
$vaultroot = "c:\dkvault"
if(-not (Test-Path "$vaultroot"))
{
Write-Host "Creating vault_config ..." -ForegroundColor Green
mkdir "$vaultroot\vault_config" | Out-Null
@praveenc
praveenc / elevateProvision.ps1
Last active March 4, 2018 16:09
dofsec elevate app vm provision script
# Provisioning script for dofsec elevate app VM
# Add IIS windows feature with WeBDev Tools
Add-WindowsFeature "Web-Server","Web-Mgmt-Tools","Web-App-Dev"
# Create drop folders for elevate app
if(-not (Test-Path "c:\dofsec"))
{
mkdir "c:\dofsec" | Out-Null
}
# Provisioning script for dofsec elevate app VM
# Create drop folders for elevate app
if(-not (Test-Path "c:\dofsec"))
{
mkdir "c:\dofsec" | Out-Null
}
# Set timezone to Eastern Standard Time
Invoke-Expression "& c:\windows\system32\tzutil.exe /s ""Eastern Standard Time"""
@praveenc
praveenc / generate-randompwd.ps1
Last active April 5, 2018 06:09
Random Password Generator (powershell)
# Works on Powershell Core 6.0.2
# Oneliner to Generate a Random password 16 chars
# To increase the number of password chars increase the range [0..15] to whatever you like
# Generate one random 16 digit password
$Password = ([char[]]([char]33..[char]95) + ([char[]]([char]97..[char]126)) + 0..9 | Sort-Object {Get-Random})[0..15] -join ''
$Password
# Passwords Generated could be like below (samples)
@praveenc
praveenc / Logger.ps1
Created April 6, 2018 03:52
Powershell Logger Class - log output in Log4net format
class Logger {
[string] $LogFileName = "env-init-log"
[string] $LogFilePath
# Constructor
Logger() {
$dtstart = (Get-Date -Format "yyyyMMddhhmmss").ToString()
$currdir = (Resolve-Path .).Path
@praveenc
praveenc / nginx-dotnetcore-default
Last active April 23, 2018 18:33
configure nginx as a reverse proxy to forward requests to ASP.NET Core app
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;