This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hints: https://github.com/PowerShell/ODataUtils | |
# some preparation work for connection to a Redfish endpoint | |
# enable TLS v1.1 as required by Redfish spec | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls11 | |
# allow self-signed server certificates | |
if ([System.Net.ServicePointManager]::CertificatePolicy.GetType().Name -ne 'TrustAllCertsPolicy') | |
{ | |
Add-Type 'using System.Net;using System.Security.Cryptography.X509Certificates;public class TrustAllCertsPolicy:ICertificatePolicy {public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate,WebRequest request, int certificateProblem) {return true;}}' | |
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspiration: https://www.pipperr.de/dokuwiki/doku.php?id=windows:powershell_oracle_db_abfragen | |
# https://docs.microsoft.com/de-de/dotnet/framework/data/adonet/retrieving-and-modifying-data | |
$assemblyFile = "C:\PathToDLL\System.Data.SQLite.dll" # download precompiled binaries for .net or "System.Data.SQLite" | |
$connString = 'Data Source="file.sqlite";Version=3;' | |
$sqlCommand = "Select * from households limit 100" | |
[Reflection.Assembly]::LoadFile($assemblyFile) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<######################### | |
LINKS | |
#########################> | |
<# | |
resource: https://devops.profitbricks.com/api/s3/ | |
https://gist.github.com/chrismdp/6c6b6c825b07f680e710 | |
https://gist.github.com/tabolario/93f24c6feefe353e14bd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cool function to create a date output in another locale | |
# SOURCE: https://stackoverflow.com/questions/2379514/powershell-formatting-values-in-another-culture | |
function Using-Culture ([System.Globalization.CultureInfo]$culture =(throw "USAGE: Using-Culture -Culture culture -Script {scriptblock}"), | |
[ScriptBlock]$script=(throw "USAGE: Using-Culture -Culture culture -Script {scriptblock}")) | |
{ | |
$OldCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture | |
$OldUICulture = [System.Threading.Thread]::CurrentThread.CurrentUICulture | |
try { | |
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture | |
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"link": "https://www.example.com/datenschutzbestimmungen", | |
"title": "Datenschutz" | |
}, | |
{ | |
"link": "https://newsletterpopup.de", | |
"title": "Datenschutz_Newsletter" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create empty array for all server network interfaces | |
$server=@() | |
# run through every datacenter and append every single server to a list | |
( profitbricks datacenter list --json | ConvertFrom-JSON ) | ForEach { | |
# append data from the datacenter | |
$dataCenterId = $_.Id | |
$dataCenterName = $_.Name | |
$dataCenterLocation = $_.Location |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"DELETE FROM jobs WHERE rowid NOT IN (SELECT min(rowid) FROM jobs GROUP BY JobId)" | .\sqlite3.exe .\jobs2.sqlite | |
"VACUUM" | .\sqlite3.exe .\jobs2.sqlite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Uri]$endpoint = "https://login.mailingwork.de/webservice/webservice/json/" | |
$verb = 'getmailings' | |
$params = @{ | |
username='<username>' | |
password='<password>' | |
} | |
$result = Invoke-RestMethod -Uri "$($endpoint)$($verb)" -Method POST -Body $params -Verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# several commands via Invoke-RestMethod | |
$request = 'https://piwikdomain/index.php?module=API&method=Live.getLastVisitsDetails&idSite=1&period=day&date=today&format=JSON&token_auth=<token>' | |
$RestCall = Invoke-RestMethod -Uri $request | |
$RestCall | Export-Csv -Delimiter "`t" -Encoding "UTF8" -path whatever1.csv -NoTypeInformation | |
# single line with pipes | |
$request = 'https://piwikdomain/index.php?module=API&method=Live.getLastVisitsDetails&idSite=1&period=day&date=today&format=JSON&token_auth=<token>' | |
( Invoke-RestMethod -Uri $request ) | Select * | Export-Csv -Delimiter "`t" -Encoding "UTF8" -path whatever2.csv -NoTypeInformation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-CSV SomeFile.csv | Select *,LINENUMBER | ForEach-Object -Begin { $Line = 1 } { | |
$_.LineNumber = $Line++ | |
$_ | |
} | Export-CSV SomeFile.csv |