Skip to content

Instantly share code, notes, and snippets.

View gitfvb's full-sized avatar
👋

Florian von Bracht gitfvb

👋
View GitHub Profile
@gitfvb
gitfvb / request_emarsys_api.ps1
Last active August 17, 2018 15:17
request the emarsys api together with Escher Authentication
# change this for the emarsys request
$username = "username001"
$secret = "secret"
$url = "https://trunk-int.s.emarsys.com/api/v2/field/translate/de"
#$url = "https://trunk-int.s.emarsys.com/api/v2/settings"
@gitfvb
gitfvb / file_dialogue.ps1
Last active August 23, 2018 15:19
File Dialogue in Powershell
Add-Type -AssemblyName System.Windows.Forms
Function Get-FileName($initialDirectory, $filter)
{
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = $filter
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
@gitfvb
gitfvb / create_settings.ps1
Created August 23, 2018 15:25
settings in json files - an easy example... this can be nested, also pscustomobjects can be nested
################################################
#
# SCRIPT ROOT
#
################################################
# script root path
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript")
{ $scriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition }
@gitfvb
gitfvb / alternative_calls.ps1
Last active March 15, 2023 12:58
powershell get utc datetime
# Older style, with better compatibility
$timestampTwo = Get-Date -Format "yyyyMMddHHmmss"
$timestampTwoUTC = (Get-Date).ToUniversalTime().ToString("yyyyMMddHHmmss")
# Newer style, but not always compatible
$timestampOne = [datetime]::Now.ToString("yyyyMMddHHmmss")
$timestampOneUTC = [datetime]::UtcNow.ToString("yyyyMMddHHmmss")
@gitfvb
gitfvb / urlencode.ps1
Created October 12, 2018 10:49
url encoding powershell
[uri]::EscapeDataString("bla bla")
@gitfvb
gitfvb / install_orbit_manually.ps1
Last active July 23, 2019 14:25
install a nuget package e.g. Apteco Orbit manually without automatic updates
<#
download nuget cli tool
https://www.nuget.org/downloads
#>
# add orbit source repository for nuget
.\nuget.exe sources add -name "Apteco Orbit" -Source "https://orbit.apteco.com/FastStatsOrbitUpdateServer/nuget"
@gitfvb
gitfvb / rewrite_files.ps1
Last active December 14, 2018 16:43
Rewrite a text file via powershell and skip some lines and/or change encoding. This way is very efficient and suitable for large files.
function rewriteFile() {
param(
[Parameter(Mandatory=$true)][string]$inputPath,
[Parameter(Mandatory=$true)][int]$inputEncoding,
[Parameter(Mandatory=$true)][string]$outputPath,
[Parameter(Mandatory=$true)][int]$outputEncoding,
[Parameter(Mandatory=$false)][int]$skipFirstLines
@gitfvb
gitfvb / example.csv
Created December 19, 2018 15:41
A "watchdog" to monitor a specific folder for an event like "created, changed...". To get this automatically running it has to be included in the windows tasks.
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
CustId Straße PLZ Ort
123 D-Str. 5 52080 Aachen
456 Am Keller 2 61080 Bad Vilbel
789 Kaiserstraße 35 60329 Frankfurt am Main
@gitfvb
gitfvb / explore.ps1
Created December 20, 2018 16:31
handling and explore csv files via powershell in an efficient way
# check some rows in between
cd "<path>"
$file = Get-Item -path "filename.csv"
$readFirstLine = $true
$startLine = 121200
$endLine = 121400
@gitfvb
gitfvb / save_password.ps1
Last active December 27, 2018 13:36
Send a mail via powershell without installing any additional addon. Only SMTP required.
################################################
#
# PREPARATION / ASSEMBLIES
#
################################################
# Load scriptpath
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$scriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
} else {