Skip to content

Instantly share code, notes, and snippets.

View gjyoung1974's full-sized avatar
🎯
Focusing

Gordon Young gjyoung1974

🎯
Focusing
View GitHub Profile
@gjyoung1974
gjyoung1974 / f_Is_In_Array.js
Created October 23, 2016 15:21
A function test if an element is present in an Array.
// A function test if an element is present in an Array.
// Arrays.asList(Array).contains(string);
function f_Is_In_Array(elem, array, i) {
var len;
var indexOf = Array.prototype.indexOf;
if (array) {
if (indexOf) {
return indexOf.call(array, elem, i);
}
@gjyoung1974
gjyoung1974 / f_CreateZip.js
Created October 23, 2016 15:23
JScript create a zip file of a log directory in MSFT Windows
// create a zip file of the log directory..
function f_CreateZip() {
var shell = new ActiveXObject("Shell.Application");
var fs_obj = new ActiveXObject("Scripting.FileSystemObject");
var zipFilename = strLogPath.path + '\\' + sActiveConfig + '-LogFiles.zip';
// create an empty zipfile :-)
var zipFile = fs_obj.CreateTextFile(zipFilename, 1, 0);
zipFile.Write('PK' + String.fromCharCode(5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
//call a REST Api
var http = require('http');
var sAPIKey = '939f36408065e19b83f5f8352573257e'
var options = {
hostname: 'api.openweathermap.org',
port: 80,
path: '/data/2.5/weather?lat=33.265014&lon=-111.839105&appid=' + sAPIKey,
method: 'POST',
headers: {
@gjyoung1974
gjyoung1974 / json_post.js
Created October 28, 2016 15:51
JSON Post on Windows
//get a web resource: REST Api Post
var apiKey = '939f36408065e19b83f5f8352573257e';
function c3rl() {
try {
var xhr = new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
xhr.open("POST", 'http://api.openweathermap.org/data/2.5/weather?lat=33.265019&lon=-111.839103&appid=' + apiKey, false);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Accept', 'application/json');
// Gordon Young 2016 gyoung@svb.com
// This script :
// 1. Reads the given Windows registry subkey value reg_multi_sz data type
// 2. Compares it to the provided expected setting
// if the configured setting is compliant the script returns 'pass',
// if the setting is non-compliant the script returns 'fail'
//The registry path we want to test
var hklm = 0x80000002, KeyName = "SYSTEM\\CurrentControlSet\\services\\Netlogon\\Parameters", ValueName = "RequireStrongKey";
@gjyoung1974
gjyoung1974 / read_reg_multi_sz_value.js
Last active December 15, 2016 08:23
read a MSFT Windows reg_multi_sz windows registry key/value and compare with expected setting
// Gordon Young 2016 gyoung@svb.com
// This script :
// 1. Reads the given Windows registry subkey value reg_multi_sz data type
// 2. Compares it to the provided expected setting
// if the configured setting is compliant the script returns 'pass',
// if the setting is non-compliant the script returns 'fail'
//The registry path we want to test
var hklm = 0x80000002, KeyName = "SYSTEM\\CurrentControlSet\\Control\\SecurePipeServers\\winreg\\AllowedExactPaths", ValueName = "Machine";
/**
* Gordon Young gjyoung1974@gmail.com
* Windows Registry Write template
*/
// Instantiate a Windows Shell
var objShell = new ActiveXObject("WScript.Shell");
//disable DisableWindowsConsumerFeature
objShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Policies\\Microsoft\\Windows\\System\\AllowDomainPINLogon", 0, "REG_DWORD");
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormer Beta - template creation prototype application. This tool allows you to create an AWS CloudFormation template from the AWS resources in your AWS account. **Warning** This template creates a single EC2 instance in your account to run the application - you will be billed for the instance at normal AWS EC2 rates.",
"Parameters": {
"Username": {
"Description": "Username to log in to CloudFormer",
"Type": "String"
},
"Password": {
"Description": "Password to log in to CloudFormer",
#!/bin/bash
#====================================================================================
# Name : certenroll_mac.sh
# Author : Gordon Young, gjyoung1974@gmail.com
# Version : .01
# Copyright : 2016 Gordon Young
# Description : A script to enroll a Mac OSX 10.11 device for a machine certificate
# : via a Microsoft Certificate Services CA
# Reference : This script supports the requirements in
#Set up some variables for later use.
$seperator = "=",","
$ADConfiguration = Get-ADRootDSE | Select configurationNamingContext
$OIDPath = "AD:\CN=OID,CN=Public Key Services,CN=Services," + $ADConfiguration.configurationNamingContext.ToString()
#Pull the AD certificates from the object
$computerObject = Get-ADComputer -Filter *
#Forced to iterate through each computer so we can manipulate it later
ForEach ($computer in $ComputerObject.Name) {