Skip to content

Instantly share code, notes, and snippets.

View crshnbrn66's full-sized avatar

Thom Schumacher crshnbrn66

View GitHub Profile
@crshnbrn66
crshnbrn66 / cortex.sh
Created September 21, 2023 17:33 — forked from szampardi/cortex.sh
use a json file for shell vars
#!/usr/bin/env bash
CORTEX_CRYPTO="aes-256-cbc"
_cortex_logger() { printf '{%s}[%s](%s):%s\t%s\n' "$(date -u '+%FT%TZ')" "${1}" "$(caller)" "${2}" "${@:3}" 1>&2; }
_cortex_io() {
case "${CORTEX_FILE}" in
"") _cortex_logger "$(caller)" ERR "CORTEX_FILE environment variable is empty/unset" && return 127 ;;
*)

Keybase proof

I hereby claim:

  • I am crshnbrn66 on github.
  • I am crshnbrn66 (https://keybase.io/crshnbrn66) on keybase.
  • I have a public key ASDg8XSrh3XHkITuTYz09EtP2CEUPYp9pYH3-S1cZpL4AAo

To claim this, I am signing this object:

function Get-FileNameProperties
{
param( $path = "~",
[switch] $Recurse,
[array]$Properties = ('Fullname', 'LastAccessTime', 'LastWriteTime', 'CreationTime','Owner','Size','Directory','Extension'))
$sortedfiles = $null
$files = Get-ChildItem -Recurse:$Recurse -File $path #if $recurse is true it'll recurse other wise it won't
$params2 = @()
function get-redirectedUrls
{
Param($url)
$urlcheckobject=@{}
$Uri = [uri]$url
$url2check = $url
do{
$value = get-redirectedUrl -url $url2check
if($value.redirect)
{
function findit
{
param
(
[Parameter(Mandatory=$True,Position=0)][string]$SearchString,
[Parameter(Mandatory=$False)]$Path = "$env:USERPROFILE\Documents",
[Parameter(Mandatory=$False)]$Filter = "*.ps1"
)
Get-ChildItem -Path $Path -Filter $Filter -Recurse | Select-String $SearchString | select path, @{n="MatchingLines";e={"$($_.LineNumber.tostring("000")): $($_.Line -replace "^[ \t]*",'')"}} | group path | select name, @{n="Matches";e={$_.Group.MatchingLines | Out-String}} | Out-GridView -PassThru | %{notepad -filenames $_.name}
}
function Get-CMLog
{
<#
.SYNOPSIS
Parses logs for System Center Configuration Manager.
.DESCRIPTION
Accepts a single log file or array of log files and parses them into objects. Shows both UTC and local time for troubleshooting across time zones.
.PARAMETER Path
Specifies the path to a log file or files.
.INPUTS
param($tnsnamesPath = 'c:\tns\tnsnames.ora',$username = 'user',$password = 'gotmehere', $connectionName = 'mustard', $query = 'Select sysdate from dual')
$simplySQLPath = (Get-Module -ListAvailable simplySQL).ModuleBase
if($simplySQLPath -and (test-path $tnsnamesPath -PathType Leaf) -and (![string]::IsNullOrEmpty($node)))
{
[System.Reflection.Assembly]::LoadFile("$simplySQLPath\DataReaderToPSObject.dll") | OUT-NULL
Import-Module SimplySql -Force
$parsedTN = (get-content $tnsnamesPath -raw) -replace '(.*\=.*|\n.*\=)(.*|\n.*)\(DESCRIPTION*.\=' ,'Data Source = (DESCRIPTION ='
$splitTN = $parsedTN -split '(?=.*Data Source = \(DESCRIPTION \=)'
$tnsnames = $splitTN |?{$_ -like "*$connectionName*"}
$connstring = "$tnsnames;User Id=$username;Password=$password"
param($dacpacPath = 'c:\dacpacPath', $dacpac = 'your.dacpac')
add-type -path 'C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\Microsoft.SqlServer.Dac.Extensions.dll'
cd $dacpacPath
$model =[Microsoft.SqlServer.Dac.Model.TSqlModel]::new(((get-item ".\$dacpac").fullname))
$queryScopes = [Microsoft.SqlServer.Dac.Model.DacQueryScopes]::All
$returnObjects = $model.GetObjects([Microsoft.SqlServer.Dac.Model.DacQueryScopes]::All)
$s = ''
foreach($r in $returnObjects)
{
if ($r.TryGetScript([ref]$s))
function Start-ConnectionMonitoring
{
param($isp, $gateway, $Logfile,[int]$Delay = 10,[Ipaddress] $adapter, [switch]$ispPopup, [switch]$gateWayPopup)
$spacer = '--------------------------'
while($true)
{
if(!(Test-Connection $gateway -source $adapter -count 1 -ea Ignore))
{
get-date | Add-Content -path $Logfile
"$gateWay Connection Failure" |add-content -Path $Logfile
@crshnbrn66
crshnbrn66 / update-AppSettings.ps1
Created October 20, 2017 18:16
Script to demonstrate hashtable merging in powershell and updating web applications in azure
param($websitename = 'TEst' ,$resourceGroup = 'SchuTest',$slot = 'production', $appSettings ='{"AppSettings:testkey1": "45test","AppSettings:TestId": "This is a Test Key 28"}')
#https://stackoverflow.com/questions/8800375/merging-hashtables-in-powershell-how
Function Merge-Hashtables([ScriptBlock]$Operator) {
$Output = @{}
ForEach ($Hashtable in $Input) {
If ($Hashtable -is [Hashtable]) {
ForEach ($Key in $Hashtable.Keys) {$Output.$Key = If ($Output.ContainsKey($Key)) {@($Output.$Key) + $Hashtable.$Key} Else {$Hashtable.$Key}}
}
}
If ($Operator) {ForEach ($Key in @($Output.Keys)) {$_ = @($Output.$Key); $Output.$Key = Invoke-Command $Operator}}