Skip to content

Instantly share code, notes, and snippets.

View gitfvb's full-sized avatar
👋

Florian von Bracht gitfvb

👋
View GitHub Profile
@gitfvb
gitfvb / size_of_dbs.sql
Created August 9, 2019 14:36
MSSQL SQL Server
SELECT [Database Name] = DB_NAME(database_id),
[Type] = CASE WHEN Type_Desc = 'ROWS' THEN 'Data File(s)'
WHEN Type_Desc = 'LOG' THEN 'Log File(s)'
ELSE Type_Desc END,
[Size in MB] = CAST( ((SUM(Size)* 8) / 1024.0) AS DECIMAL(18,2) )
FROM sys.master_files
GROUP BY GROUPING SETS
(
(DB_NAME(database_id), Type_Desc),
(DB_NAME(database_id))
@gitfvb
gitfvb / epi__0__create_settings.ps1
Last active July 15, 2019 10:58
EpiServer Campaign Handling via PowerShell with strong encrypted session keys and passwords
################################################
#
# SCRIPT ROOT
#
################################################
# Load scriptpath
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$scriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
@gitfvb
gitfvb / test_encrypted_strings.ps1
Last active July 15, 2019 09:14
Encrypt and decrypt string (like tokens) securely in PowerShell. This can be used to save tokens safely in a text file. The encryption key will be generated on the fly.
################################################
#
# SCRIPT ROOT
#
################################################
# Load scriptpath
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$scriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
} else {
@gitfvb
gitfvb / epi_loosetyped.ps1
Created July 12, 2019 22:42
EpiServer Campaign SOAP calls via PowerShell
<#
https://world.episerver.com/documentation/developer-guides/campaign/SOAP-API/introduction-to-the-soap-api/webservice-overview/
WSDL: https://api.campaign.episerver.net/soap11/RpcSession?wsdl
#>
#---------------------------
# SETTINGS
#---------------------------
@gitfvb
gitfvb / sqlserverstats.sql
Created June 30, 2019 14:50
SQL Server stats
# Space and rows of SQL-Server Database
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
FROM
sys.tables t
INNER JOIN
@gitfvb
gitfvb / shutdown.ps1
Created June 10, 2019 22:57
Windows shutdown via command
# shutdown in 90 minutes (5400 seconds)
shutdown /s /t 5400
# abort shutdown
shutdown /a
@gitfvb
gitfvb / create_link.ps1
Created May 8, 2019 12:38
Symbolic links using Powershell
@gitfvb
gitfvb / splitfile.ps1
Created April 26, 2019 14:33
Function to split a file into parts
function Split-File{
param(
$inFile,
$outPrefix,
[Int32] $bufSize
)
$file = Get-Item -Path $inFile
@gitfvb
gitfvb / orbit_api.ps1
Last active January 21, 2020 15:50
Example of how to handle the Apteco Orbit API / FastStats API v2
<#
NOTES
* swagger: http://www.tealgreenholidays.co.uk/OrbitAPI/swagger/ui/index.html#/About/About_GetDataViews
#>
################################################
#