Skip to content

Instantly share code, notes, and snippets.

View ryancbutler's full-sized avatar

Ryan Butler ryancbutler

View GitHub Profile
@ryancbutler
ryancbutler / letauto.sh
Last active January 14, 2016 05:43
LetsEncrypt SAN Script for Netscaler
#!/bin/sh
#
# Wrapper script for the letsencrypt client to generate a server certificate in
# manual mode. It uses openssl to generate the key and should not modify the
# server configuration. It can be called off-side, i.e. not on the destination
# server.
#
# usage: gencert DOMAIN [DOMAIN...]
#
# This is free and unencumbered software released into the public domain.

Keybase proof

I hereby claim:

  • I am ryancbutler on github.
  • I am ryancbutler (https://keybase.io/ryancbutler) on keybase.
  • I have a public key whose fingerprint is 63AA 4FEC 6155 9E4E 9B94 47EB 1058 8308 10A0 87E8

To claim this, I am signing this object:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$username = "nsroot"
$password = "nsroot"
$nsip = "https://192.168.1.50"
$body = ConvertTo-JSON @{
"login"=@{
"username"="$username";
@ryancbutler
ryancbutler / Get-CTXPolObj.ps1
Created August 17, 2017 16:52
Converts Citrix Policy to easily readable PS object
#Converts Citrix Policy to easily readable PS object
function Get-CTXPolObj ($pol)
{
$temp = @()
foreach ($settings in $pol)
{
foreach($setting in $settings.psobject.properties)
{
$Object = New-Object PSObject
<#
.SYNOPSIS
Outputs to a UTF-8-encoded file *without a BOM* (byte-order mark).
.DESCRIPTION
Mimics the most important aspects of Out-File:
* Input objects are sent to Out-String first.
* -Append allows you to append to an existing file, -NoClobber prevents
overwriting of an existing file.
* -Width allows you to specify the line width for the text representations
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue )
#Dot source the files
Foreach($import in @($Public + $Private))
{
Try
{
. $import.fullname
}
$module = "C:\Temp\Citrix.GroupPolicy.Commands.psm1"
#Import-Module $module -force
New-PSDrive -Name LocalFarmGpo -PSProvider CitrixGroupPolicy -root \ -controller "localhost"
New-PSDrive -Name ADGpo -PSProvider CitrixGroupPolicy -root \ -domain "CITRIX - TEST GPO 0"
Export-CtxGroupPolicy -FolderPath "C:\temp\exported" -DriveName "LocalFarmGpo"
Import-CtxGroupPolicy -FolderPath "C:\temp\exported" -DriveName "ADGpo"
$filters = Import-Clixml "C:\temp\exported\GroupPolicyFilter.xml"
#RUN AS ADMIN. WILL ERROR OUT ON CONNECTION
CLS
#SET TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Function Get-StringHash([String] $String,$HashName = "MD5")
{
$StringBuilder = New-Object System.Text.StringBuilder
[System.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))|%{
version: '2'
services:
cpx:
image: store/citrix/netscalercpx:12.0-56.20
tty: true
ports:
- "8888:8888" #VIP Port to be used
- "8080:80" #NSIP Mapping HTTP
- "8443:443" #NSIP Mapping HTTPS
- "8022:22" #NSIP Mapping SSH
$sb = {
<#
.Synopsis
Here is the PowerShell CmdLet that would enable AutoLogon next time when the server reboots.We could trigger a specific Script to execute after the server is back online after Auto Logon.
The CmdLet has the follwing parameter(s) and function(s).
-DefaultUsername : Provide the username that the system would use to login.
-DefaultPassword : Provide the Password for the DefaultUser provided.
-AutoLogonCount : Sets the number of times the system would reboot without asking for credentials.Default is 1.
-Script : Provide Full path of the script for execution after server reboot. Example : c:\test\run.bat