Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian von Bracht gitfvb

View GitHub Profile
@gitfvb
gitfvb / binary_cleverreach.ps1
Created Jun 22, 2020
Binary options in powershell
View binary_cleverreach.ps1
<#
HINTS
# check bitwise: https://ingogegenwarth.wordpress.com/2016/11/17/powershell-and-bit-field-attributes/
#>
# Good example because the cleverreach api checks the details to download bitwise... those are the values
$cleverreachDetails = @{
events = 1
@gitfvb
gitfvb / Get-Unixtime.ps1
Created Jun 9, 2020
Huspot outlines in PowerShell
View Get-Unixtime.ps1
# current unixtimestamp with the optional milliseconds
Function Get-Unixtime {
param(
[Parameter(Mandatory=$false)][switch] $inMilliseconds = $false
,[Parameter(Mandatory=$false)][DateTime] $timestamp = ( Get-Date )
)
$multiplier = 1
@gitfvb
gitfvb / checkBackupsAndSpace.ps1
Created Jun 8, 2020
Quick example to check the amount of backups and the current used and free space on all local drives and send that information via smtp
View checkBackupsAndSpace.ps1
$logfile = "D:\Apteco\Log\backup_manual.log"
# log
"$( [datetime]::Now.ToString("yyyyMMddHHmmss") )`t-------------------------------" >> $logfile
# Get all local drives that are currently used (used space greater than 0) and format the numbers and output as list
$currentSpace = Get-PSDrive -PSProvider FileSystem | where { $_.Used -gt 0 } | Select Root, @{name="Used (GB)";expression={ ($_.Used/1GB).ToString(".00") }}, @{name="Free (GB)";expression={ ($_.Free/1GB).ToString(".00") }} | fl
# check how many backups are in a folder
$backupFolder = "D:\Apteco\Publish\<sysname>\backup\"
@gitfvb
gitfvb / dayByDay.ps1
Last active Jun 8, 2020
Calculate a month in textform for a diary through PowerShell
View dayByDay.ps1
[int]$month = Read-Host -Prompt "Monat" # In Nummern wie 6
[int]$year = Read-Host -Prompt "Jahr" # In Nummer wie 2020
$firstDay = Get-Date -Day 01 -Month $month -Year $year
$firstDayNextMonth = Get-Date -Day 01 -Month ( $month + 1 ) -Year $year
$currentDay = $firstDay
cls
@gitfvb
gitfvb / backup.ps1
Created Feb 6, 2020
Daily backup and cleanup for folders in PowerShell
View backup.ps1
################################################
#
# SETTINGS
#
################################################
$foldersToBackup = @(
"D:\Apteco\Publish\holidays\private"
"D:\Apteco\Publish\holidays\public"
View aachen_postal_codes.txt
area["name"="Aachen"][boundary=administrative]->.myarea;
rel(area.myarea)["boundary"="postal_code"];
out geom;
@gitfvb
gitfvb / loop_inserts.sql
Last active Dec 9, 2019
Outline to page through MSSQL inserts (especially helpful for big joins)
View loop_inserts.sql
/* Drop temporary table if exists */
DROP TABLE IF EXISTS #CommTestefd5adf666914ec88906066cdcf4de1f
/* Create a temporary table */
CREATE TABLE #CommTestefd5adf666914ec88906066cdcf4de1f
(
[Id] [int] NOT NULL,
[Urn] [sql_variant] NULL,
[StepId] [int] NULL,
[StateId] [int] NULL,
@gitfvb
gitfvb / jwt.ps1
Created Nov 1, 2019
create a standard jwt token in PowerShell
View jwt.ps1
<#
based on this example from: https://jwt.io/
https://stackoverflow.com/questions/30246497/using-statement-for-base64urlencode
https://medium.com/@nikitafed9292/net-base64-decoding-workaround-82b797162b6e
https://blog.angular-university.io/angular-jwt/
https://gist.github.com/kucukkanat/1ef77db8120323db2b89087735ef8a5d
#>
################################################
@gitfvb
gitfvb / base64.ps1
Created Nov 1, 2019
Base64 String converting in PowerShell because some frameworks trim the "=" at the end
View base64.ps1
# source of functions: https://medium.com/@nikitafed9292/net-base64-decoding-workaround-82b797162b6e
# Add missing "=" at the end
Function Check-Base64 {
param(
[Parameter(Mandatory=$true)][String]$inputString
)
$input
@gitfvb
gitfvb / read_wsdl.ps1
Last active Oct 29, 2019
first try to read and parse SOAP wsdl in powershell
View read_wsdl.ps1
$wsdlUrl = "https://soap.flexmail.eu/3.0.0/flexmail.wsdl"
$wsdlContent = Invoke-RestMethod -Method Get -Uri $wsdlUrl -Verbose
# metadata
$targetNamespace = $wsdlContent.definitions.targetNamespace
$bindingStyle = $wsdlContent.definitions.binding.binding.style
# operations (different ways)
$operations1 = $wsdlContent.definitions.binding.operation
You can’t perform that action at this time.