Skip to content

Instantly share code, notes, and snippets.

@fxm73
fxm73 / EmbeddedPassword.ps1
Created May 12, 2017 03:10 — forked from davefunkel/EmbeddedPassword.ps1
Embedded Credentials in a PowerShell Script
$username = "[email protected]"
$password = "Password123!@#"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user, $secureStringPwd
$secureStringText = $secureStringPwd | ConvertFrom-SecureString
Set-Content "C:\temp\ExportedPassword.txt" $secureStringText
$username = "[email protected]"
$pwdTxt = Get-Content "C:\temp\ExportedPassword.txt"
$securePwd = $pwdTxt | ConvertTo-SecureString
$credObject = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securePwd
# Generate a random AES Encryption Key.
$AESKey = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($AESKey)
# Store the AESKey into a file. This file should be protected! (e.g. ACL on the file to allow only select people to read)
Set-Content $AESKeyFilePath $AESKey # Any existing AES Key file will be overwritten
$password = $passwordSecureString | ConvertFrom-SecureString -Key $AESKey
Add-Content $credentialFilePath $password
@fxm73
fxm73 / Script-Template-WithCreds.ps1
Created May 12, 2017 03:10 — forked from davefunkel/Script-Template-WithCreds.ps1
PowerShell Script Template with Saved Creds
<#
.SYNOPSIS
The synopsis goes here. This can be one line, or many.
This version of the template has inbuilt functions to capture credentials and store it securely for reuse
Avoids the need to have plaintext passwords in the script
.DESCRIPTION
The description is usually a longer, more detailed explanation of what the script or function does.
Take as many lines as you need.
$username = "[email protected]"
$AESKey = Get-Content $AESKeyFilePath
$pwdTxt = Get-Content $SecurePwdFilePath
$securePwd = $pwdTxt | ConvertTo-SecureString -Key $AESKey
$credObject = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securePwd
@fxm73
fxm73 / iptables_rules.sh
Created December 4, 2016 23:17 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@fxm73
fxm73 / Convert-PfxToPem.psm1
Created June 21, 2016 02:59
OpenSSL wrapper to convert a .pfx (e.g. from ADCA) into .pem
Function Convert-PfxToPem {
param(
[Parameter( Mandatory=$true,
Position=0,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage="pfx filepath")]
[ValidateScript({Test-Path $_})]
[Alias("PsPath")]
[string[]]$pfx,
@fxm73
fxm73 / ITGuyV2
Created June 21, 2016 02:52 — forked from anonymous/ITGuyV2
Admin-i-nator
# ==============================================================================================
# ==============================================================================================
# =============================== Admin-i-Nator V2 Update 2 ====================================
# ============= This version has been updated to reflect permission changes with new ===========
# ============= Admin accounts; all account creation tools have been commented out =============
# ==============================================================================================
# ============= Recent Changes: ================
# ============= 16 December 2015 - Added button to install updated flash ================
# ============= 16 December 2015 - Removed Office install option ================
# ==============================================================================================
##########
# Tweaked Win10 Initial Setup Script
# Primary Author: Disassembler <[email protected]>
# Original Version: 1.4, 2016-01-16
# Tweaked based on personal preferences for @alirobe 2016-03-23 - v1.4.1
# NOTE: MAKE SURE YOU READ THIS SCRIPT CAREFULLY BEFORE RUNNING IT + ADJUST COMMENTING AS APPROPRIATE
# This script will reboot your machine when completed.
##########
# Ask for elevated permissions if required