Skip to content

Instantly share code, notes, and snippets.

View FracVX's full-sized avatar
🎯
Focusing

Erick Moreno FracVX

🎯
Focusing
View GitHub Profile
@FracVX
FracVX / Script-Template-WithCreds.ps1
Created October 20, 2017 20:19 — 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.
@FracVX
FracVX / WindowsCredentialVault.psm1
Created February 13, 2018 18:36 — forked from guitarrapc/WindowsCredentialVault.psm1
PowerShell Windows Credential Vault Module
function InitializeWindowsCredential
{
Write-Verbose ("Loading PasswordVault Class.")
[void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
}
InitializeWindowsCredential
function ConvertTo-PasswordCredential
{
@FracVX
FracVX / Get-CredentialFromWindowsCredentialManager.ps1
Created February 13, 2018 18:48 — forked from cdhunt/Get-CredentialFromWindowsCredentialManager.ps1
Gets a PowerShell Credential [PSCredential] from the Windows Credential Manager. This only works for Generic Credentials.
<#
.SYNOPSIS
Gets a PowerShell Credential (PSCredential) from the Windows Credential Manager
.DESCRIPTION
This module will return a [PSCredential] object from a credential stored in Windows Credential Manager. The
Get-StoredCredential function can only access Generic Credentials.
Alias: GSC
@FracVX
FracVX / Delete-AllCmdKeyCredentials.ps1
Created September 4, 2018 20:28 — forked from janikvonrotz/Delete-AllCmdKeyCredentials.ps1
PowerShell: Delete all cmdkey credentials #PowerShell #Windows
cmdkey /list | ForEach-Object{if($_ -like "*Ziel:*"){cmdkey /del:($_ -replace " ","" -replace "Ziel:","")}}
@FracVX
FracVX / ConvertFrom-DNorCanonical
Created March 25, 2019 16:22 — forked from joegasper/ConvertFrom-DN
Convert between DistinguishedName and CanonicalName
function ConvertFrom-DN {
[cmdletbinding()]
param(
[Parameter(Mandatory,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[ValidateNotNullOrEmpty()]
[string[]]$DistinguishedName
)
process {
foreach ($DN in $DistinguishedName) {
Write-Verbose $DN
@FracVX
FracVX / powershell.json
Created July 9, 2019 19:01 — forked from rkeithhill/powershell.json
PowerShell snippets file for Visual Studio Code - place in your ~\AppData\Roaming\Code\User\Snippets directory
{
"Condition statement": {
"prefix": "cond",
"body": [
"${_} { ${0}; break }"
],
"description": "Switch condition statement"
},
"Condition single quoted string statement": {
Function New-Employee {
[cmdletbinding()]
param(
[Parameter(Mandatory)]
$EmployeeID,
[Parameter(Mandatory)]
$FirstName,
[Parameter(Mandatory)]
@FracVX
FracVX / cloudflare-ddns-update.sh
Created September 17, 2019 23:21 — forked from Tras2/cloudflare-ddns-update.sh
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@FracVX
FracVX / Split-File.ps1
Created February 21, 2020 22:35 — forked from awayken/Split-File.ps1
Split files using Powershell, modified from: http://stackoverflow.com/a/11010158/215200
# Modified from: http://stackoverflow.com/a/11010158/215200
$fromFolder = "D:\FOLDER\"
$rootName = "FILENAME"
$ext = "EXT"
$from = "{0}{1}.{2}" -f ($fromFolder, $rootName, $ext)
$fromFile = [io.file]::OpenRead($from)
$upperBound = 100MB
@FracVX
FracVX / ConvertTo-DistinguishedName.ps1
Created February 11, 2021 05:27 — forked from wolffberg/ConvertTo-DistinguishedName.ps1
Function to check and convert CanonicalName to DestinguishedName
function ConvertTo-DistinguishedName{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
$CanonicalName
)
Begin{
# StringBuilders used to build DestinguishedName and LDAP query
$dn = [System.Text.StringBuilder]::new()
$ldapQuery = [System.Text.StringBuilder]::new()