An open API service indexing awesome lists of open source software.

https://github.com/apteco/aptecopsmodules

Apteco PowerShell Modules
https://github.com/apteco/aptecopsmodules

apteco powershell powershell-module powershell-script windows

Last synced: about 1 year ago
JSON representation

Apteco PowerShell Modules

Awesome Lists containing this project

README

          

[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/PlagueHO/PSAuth/blob/dev/LICENSE)

# AptecoPSModules

The Apteco PowerShell Modules allow you to extend your current Apteco Marketing Stack with more customisation. For example here is fully featured Framework to create your own channels for Orbit and PeopleStage. Other modules in here are helpful in working with your data.

All modules are targeted to be published on [PowerShell Gallery](https://www.powershellgallery.com/packages?q=apteco). So Installation is much easier than copy&paste.

Those are the already published packages, but more are in the pipeline:

Name|Type|Repository/Version|Platform|Downloads|
-|-|-|-|-
[AptecoPSFramework](https://github.com/Apteco/AptecoPSFramework/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/AptecoPSFramework)](https://www.powershellgallery.com/packages/AptecoPSFramework)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/AptecoPSFramework)](https://www.powershellgallery.com/packages/AptecoPSFramework)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/AptecoPSFramework)](https://www.powershellgallery.com/packages/AptecoPSFramework)
[ConvertStrings](ConvertStrings/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/ConvertStrings)](https://www.powershellgallery.com/packages/ConvertStrings)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/ConvertStrings)](https://www.powershellgallery.com/packages/ConvertStrings)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/ConvertStrings)](https://www.powershellgallery.com/packages/ConvertStrings)
[ConvertUnixTimestamp](ConverUnixTimestamp/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/ConvertUnixTimestamp)](https://www.powershellgallery.com/packages/ConvertUnixTimestamp)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/ConvertUnixTimestamp)](https://www.powershellgallery.com/packages/ConvertUnixTimestamp)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/ConvertUnixTimestamp)](https://www.powershellgallery.com/packages/ConvertUnixTimestamp)
[EncryptCredential](EncryptCredential/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/EncryptCredential)](https://www.powershellgallery.com/packages/EncryptCredential)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/EncryptCredential)](https://www.powershellgallery.com/packages/EncryptCredential)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/EncryptCredential)](https://www.powershellgallery.com/packages/EncryptCredential)
[ExtendFunction](ExtendFunction/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/ExtendFunction)](https://www.powershellgallery.com/packages/ExtendFunction)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/ExtendFunction)](https://www.powershellgallery.com/packages/ExtendFunction)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/ExtendFunction)](https://www.powershellgallery.com/packages/ExtendFunction)
[InvokeWebRequestUTF8](InvokeWebRequestUTF8/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/InvokeWebRequestUTF8)](https://www.powershellgallery.com/packages/InvokeWebRequestUTF8)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/InvokeWebRequestUTF8)](https://www.powershellgallery.com/packages/InvokeWebRequestUTF8)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/InvokeWebRequestUTF8)](https://www.powershellgallery.com/packages/InvokeWebRequestUTF8)
[MeasureRows](MeasureRows/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/MeasureRows)](https://www.powershellgallery.com/packages/MeasureRows)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/MeasureRows)](https://www.powershellgallery.com/packages/MeasureRows)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/MeasureRows)](https://www.powershellgallery.com/packages/MeasureRows)
[MergeHashtable](MergeHashtable/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/MergeHashtable)](https://www.powershellgallery.com/packages/MergeHashtable)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/MergeHashtable)](https://www.powershellgallery.com/packages/MergeHashtable)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/MergeHashtable)](https://www.powershellgallery.com/packages/MergeHashtable)
[MergePSCustomObject](MergePSCustomObject/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/MergePSCustomObject)](https://www.powershellgallery.com/packages/MergePSCustomObject)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/MergePSCustomObject)](https://www.powershellgallery.com/packages/MergePSCustomObject)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/MergePSCustomObject)](https://www.powershellgallery.com/packages/MergePSCustomObject)
[SyncExtractOptions](SyncExtractOptions/)|Script|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/SyncExtractOptions)](https://www.powershellgallery.com/packages/SyncExtractOptions)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/SyncExtractOptions)](https://www.powershellgallery.com/packages/SyncExtractOptions)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/SyncExtractOptions)](https://www.powershellgallery.com/packages/SyncExtractOptions)
[WriteLog](WriteLog/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/WriteLog)](https://www.powershellgallery.com/packages/WriteLog)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/WriteLog)](https://www.powershellgallery.com/packages/WriteLog)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/WriteLog)](https://www.powershellgallery.com/packages/WriteLog)
[Install-Dependencies](Install-Dependencies/)|Script|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/Install-Dependencies)](https://www.powershellgallery.com/packages/Install-Dependencies)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/Install-Dependencies)](https://www.powershellgallery.com/packages/Install-Dependencies)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/Install-Dependencies)](https://www.powershellgallery.com/packages/Install-Dependencies)
[Import-Dependencies](Import-Dependencies/)|Script|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/Import-Dependencies)](https://www.powershellgallery.com/packages/Import-Dependencies)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/Import-Dependencies)](https://www.powershellgallery.com/packages/Import-Dependencies)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/Import-Dependencies)](https://www.powershellgallery.com/packages/Import-Dependencies)
[PSOAuth](PSOAuth/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/PSOAuth)](https://www.powershellgallery.com/packages/PSOAuth)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/PSOAuth)](https://www.powershellgallery.com/packages/PSOAuth)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSOAuth)](https://www.powershellgallery.com/packages/PSOAuth)
[TestCredential](TestCredential/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/TestCredential)](https://www.powershellgallery.com/packages/TestCredential)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/TestCredential)](https://www.powershellgallery.com/packages/TestCredential)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/TestCredential)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/TestCredential)](https://www.powershellgallery.com/packages/TestCredential)
[PSNotify](PSNotify/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/PSNotify)](https://www.powershellgallery.com/packages/PSNotify)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/PSNotify)](https://www.powershellgallery.com/packages/PSNotify)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSNotify)](https://www.powershellgallery.com/packages/PSNotify)
[SqlPipeline](SqlPipeline/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/SqlPipeline)](https://www.powershellgallery.com/packages/SqlPipeline)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/SqlPipeline)](https://www.powershellgallery.com/packages/SqlPipeline)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/SqlPipeline)](https://www.powershellgallery.com/packages/SqlPipeline)
[OSMGeocode](OSMGeocode/)|Module|[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/OSMGeocode)](https://www.powershellgallery.com/packages/OSMGeocode)|[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/OSMGeocode)](https://www.powershellgallery.com/packages/OSMGeocode)
[![Minimum Supported PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-blue.svg)](https://github.com/PlagueHO/PSAuth)|[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/OSMGeocode)](https://www.powershellgallery.com/packages/OSMGeocode)

Here are some high level descriptions. Please follow the links from the table or go into the subdirectories to get more detailed information.

## AptecoPSFramework

This framework is mainly created for installing and using custom channels in Apteco Orbit and PeopleStage. The channel implementations are written in PowerShell and already implemented as "Plugins" in this module. But there is a function implemented so you can refer to your own channels that are not getting overwritten if you update this module.

## ConvertStrings

Allow you to manipulate strings like converting the string encoding or replacing strings. Random strings and hashed strings are also included.

## MergePSCustomObject

This module merges two PSCustomObjects into one. It is able to handle nested structures like hashtables, arrays and PSCustomObjects.

## ConvertUnixTimestamp

Converts a `[DateTime]` into a numeric unix timestamp as `[UInt64]` and vice versa.

To get a unix timestamp from a `[DateTime]::Now` or `(Get-Date)` just do it like in these examples

```PowerShell
Get-Unixtime
Get-Unixtime -InMilliseconds
Get-Unixtime -InMilliseconds -Timestamp ( Get-Date ).AddDays(-2)
```

To convert a timestamp back, just do it like here

```PowerShell
ConvertFrom-UnixTime -Unixtime 1591775090
ConvertFrom-UnixTime -Unixtime 1591775090 -ConvertToLocalTimezone
ConvertFrom-UnixTime -Unixtime 1591775146091 -InMilliseconds
( ConvertFrom-UnixTime -Unixtime $lastSession.timestamp ).ToString("yyyy-MM-ddTHH:mm:ssK")
```

## EncryptCredential

This module is used to double encrypt sensitive data like credentials, tokens etc. They cannot be stolen pretty easily as it uses SecureStrings.

Execute commands like

```PowerShell
"Hello World" | Convert-PlaintextToSecure
```

to get a string like

```
76492d1116743f0423413b16050a5345MgB8AEEAYQBmAEEAOABPAEEAYQBmAEYAKwBuAGQAegBxACsASQBRAGIAaQA0AEEAPQA9AHwANAAxAGEAYQBhADAAYwA3ADQAYwBiADkAYwAzADEAZgBkAGUAZQBkADQAOABhADIAMgA5AGUAMAAyADkANwBiADcAMQAyADgAOAAzADkAMwBiADAANAA0ADcAMwA3ADQANgAxADMAYwBmADQAZQAyADIAMwBkAGQAMQBhADUAMAA=
```

This string can be decrypted by calling

```PowerShell
"76492d1116743f0423413b16050a5345MgB8AEEAYQBmAEEAOABPAEEAYQBmAEYAKwBuAGQAegBxACsASQBRAGIAaQA0AEEAPQA9AHwANAAxAGEAYQBhADAAYwA3ADQAYwBiADkAYwAzADEAZgBkAGUAZQBkADQAOABhADIAMgA5AGUAMAAyADkANwBiADcAMQAyADgAOAAzADkAMwBiADAANAA0ADcAMwA3ADQANgAxADMAYwBmADQAZQAyADIAMwBkAGQAMQBhADUAMAA=" | Convert-SecureToPlaintext
```

and get back

```
Hello World
```

## ExtendFunction

This module can be used to extend existing functions/cmdlets with more scripting and possibly additional parameters like

```PowerShell
function Invoke-CoreWebRequest {

[CmdletBinding()]
param (
[Parameter(Mandatory=$true)][string]$AdditionalString
)
DynamicParam { Get-BaseParameters "Invoke-WebRequest" }

Process {
Write-Host $AdditionalString
$updatedParameters = Skip-UnallowedBaseParameters -Base "Invoke-WebRequest" -Parameters $PSBoundParameters
Invoke-WebRequest @updatedParameters
}

}
```

## InvokeWebRequestUTF8

Executes an `Invoke-WebRequst`, but converts the content afterwards into UTF8, if the correct encoding wasn't given back.

## Install-Dependencies

A small script that helps you to install scripts/modules/packages you need to load via a repository like PowerShellGallery or NuGet or a local repository.

Just use

```PowerShell
Install-Dependencies -Module "WriteLog" -LocalPackage "System.Data.Sqlite", "Npgsql" -Verbose
```

## Import-Dependencies

A small script that helps you to import your installed modules and packages you have installed through PowerShellGallery, NuGet or a local repository.

Just use

```PowerShell
Import-Dependencies.ps1 -Module "WriteLog" -LoadWholePackageFolder -Verbose
```

to load your `lib` subfolder or

```Powershell
Import-Dependencies.ps1 -Module "WriteLog" -LocalPackage "System.Data.SQLite", "Npgsql" -Verbose
```

to load specific folders

## MeasureRows

Just use

```PowerShell
Measure-Rows -Path "C:\Temp\Example.csv"
```

or

```PowerShell
"C:\Temp\Example.csv" | Measure-Rows -SkipFirstRow
```

or

```PowerShell
Measure-Rows -Path "C:\Temp\Example.csv" -Encoding UTF8
```

or even

```PowerShell
"C:\Users\Florian\Downloads\adressen.csv", "C:\Users\Florian\Downloads\italian.csv" | Measure-Rows -SkipFirstRow -Encoding ([System.Text.Encoding]::UTF8)
```

to count the rows in a csv file. It uses a .NET streamreader and is extremly fast.

## MergeHashtable

This module merges two Hashtables into one. It is able to handle nested structures like hashtables, arrays and PSCustomObjects.

## MergePSCustomObject

This module merges PSCustomObjects into one. It is able to handle nested structures like hashtables, arrays and PSCustomObjects.

## OSMGeocode

Geocode single or multiple addresses on the fly via OpenStreetMaps like

```PowerShell
$addr = [PSCustomObject]@{"street" = "Schaumainkai 87";"city" = "Frankfurt";"postalcode" = 60589;"countrycodes" = "de"}
$addr | Invoke-OSM -Email "user@example.com" -AddressDetails -ExtraTags -ResultsLanguage "de"
```

## PSOAuth

Support of oAuth v2 in PowerShell! This module allows the oAuth flow to create your first api token for Microsoft Dynamics, Salesforce, CleverReach and much more...
We support redirect urls to local urls `http://localhost:54321` and app urls (handled via registry) `apttoken://localhost`. The local url is instantly starting up a
basic webserver on the port you have defined. This module can be used for debugging or server2server communication. Here you can see the two methods than can be used:

```PowerShell
import-module PSOAuth -Verbose
$oauthParam = [Hashtable]@{
"ClientId" = "ssCNo32SNf"
"ClientSecret" = "" # ask for this at Apteco, if you don't have your own app
"AuthUrl" = "https://rest.cleverreach.com/oauth/authorize.php"
"TokenUrl" = "https://rest.cleverreach.com/oauth/token.php"
"SaveSeparateTokenFile" = $true
}
Request-OAuthLocalhost @oauthParam
```

or

```PowerShell
import-module PSOAuth -Verbose
$oauthParam = [Hashtable]@{
"ClientId" = "ssCNo32SNf"
"ClientSecret" = "" # ask for this at Apteco, if you don't have your own app
"AuthUrl" = "https://rest.cleverreach.com/oauth/authorize.php"
"TokenUrl" = "https://rest.cleverreach.com/oauth/token.php"
"SaveSeparateTokenFile" = $true
}
Request-OAuthApp @oauthParam -Verbose
```

## PSNotify

Use Telegram, Email, Teams and Slack to get notifications via commandline. This can be used to be notified when important things happen like
successful campaigns or maybe occured problems. Different channels can be bound together as groups so you can send the same message through
different channels.

## SyncExtractOptions

This script is used to switch off or switch on some data sources in FastStats Designer to allow a build with only a few tables (like customer data)
and then later do a bigger build with customer and transactional data.

This example just changes the behaviour of the extract options and saves it in the same xml

```PowerShell
SyncExtractOptions -DesignFile "C:\Apteco\Build\20220714\designs\20220714.xml" -Include "Bookings", "People"
```

## SqlPipeline

To allow easier import of data into databases like PostgreSQL, SQLite, MariaDB/MySQL, SQLServer, Oracle and more there is a pretty handy
module named `SimplySql`. As this module does not support pipeline input yet, I have created this wrapper with high flexibility. So
this module allows importing csv file import like

```PowerShell
Import-Module SqlPipeline, SimplySql
Open-SQLiteConnection -DataSource ".\db.sqlite"
Measure-Command {
import-csv -Path '.ac_adressen.csv' -Encoding UTF8 -Delimiter "," | Add-RowsToSql -TableName "addresses" -UseTransaction -Verbose
}
Close-SqlConnection
```

But there is much more. Just go to that subdirectory to view the [README](SqlPipeline/) file.

# TestCredential

This module helps you to test credentials before you use them. By default, this module asks 3x times before cancelling. It delivers a `$true` or `$false` back.

Use this module in interactive mode -> this one requests your user and password, uses the current user as default

```PowerShell
Test-Credential
```

Define User and password beforehand

```PowerShell
$c = Get-Credential
Test-Credential -Credentials $c
```

OR

```PowerShell
$c = Get-Credential
Test-Credential -Credentials $c -NonInteractive
```

OR

Get-Credential | Test-Credential

## WriteLog

This script allows to write log files pretty easy without any fuzz. It retries the write commands if parallel processes want to write into the same logfile.

Execute commands like

```PowerShell
Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log
```

Then the logfile getting written looks like

```
20220217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO This is a general information
20220217134617 a6f3eda5-1b50-4841-861e-010174784e8c ERROR Note! This is an error
20220217134618 a6f3eda5-1b50-4841-861e-010174784e8c VERBOSE This is the verbose/debug information
20220217134619 a6f3eda5-1b50-4841-861e-010174784e8c WARNING And please look at this warning

```

separated by tabs.

Click on the folder for more information.