Author: freakling

  • Sending css formatted tables in Outlook

    If you’ve ever used Powershell to send HTML tables in Outlook containing CSS you’ve probably been disappointed of the outcome. There is some archived documentation for Outlook 2007 that is still viable for Outlook 365 (https://msdn.microsoft.com/en-us/library/aa338201(v=office.12).aspx). Basically the function accepts a csv and css file, hardcodes the css into the table and outputs a formatted…

  • Just enough Administration & RDS

    Reblogged from my company blog: https://tech.xenit.se/just-enough-administration-rds/ — The Problem? Microsoft RDS has limitations when delegating access, in fact there is no built-in access delegation whatsoever! The solution? Powershell! A Just enough Administration (JEA) endpoint, also known as a Constrained Powershell Endpoint. The endpoint is restricted to only access List collection, list users and subsequently force…

  • Recursively search Azure Ad group members

    Reblogged from my company blog: https://tech.xenit.se/recursively-search-azure-ad-group-members/ — When working with on-premise Active Directory an administrator often has to recursively search AD groups, this is easy using the ActiveDirectory module with cmdlet “Get-AdGroupMember <Group> -Recusive”. For the AzureAD equivalent this is no longer an option, the cmdlet Get-AzureADGroupMember has three parameters. PARAMETERS -All <Boolean> If true,…

  • Azure Automation – Running scripts locally on VM through runbooks

    Reblogged from my company blog: https://tech.xenit.se/azure-automation-running-scripts-locally-vm-runbooks/ — I was tasked to create a powershell script to run on a schedule on a Azure VM. Normally this would be running as a scheduled task on the VM but seeing as we’re working with AzureVM and schedule tasks are legacy I wanted to explore the possibilities of…

  • Powershell & Graphs

    TL;DR I wanted to draw graphs in powershell without any external dependancies. So I did, results below. How to graph: Create one or more array of points Join arrays into another array of lines Execute Draw-Graph function with some data #Build graph [Array]$Line1 = 1..12 | ForEach-Object{Get-Random (10..20)} $p=Get-Random (14..25) $p%5 [Array]$Line2 = 1..12 |…

  • Generate-Key

    To compliment my earlier post I have created a short function to generate keys. Function Generate-key{ Param( [validateset(128,192,256)] $bits, [switch]$COUT, $seed ) $bytes = $bits/8 $array = @() If($seed){ 1..$bytes | ForEach-Object{ $array += Get-Random -Minimum 0 -Maximum 255 -SetSeed $seed } } Else{ 1..$bytes | ForEach-Object{ $array += Get-Random -Minimum 0 -Maximum 255 }…

  • Encrypting strings with custom keys in powershell

    Since the ConvertTo-SecureString is not really secure, and neither is the EncodedCommand (base64string) I made two short functions to encrypt and decrypt strings in order to send them across the void unharmed. Function Encrypt-String{ Param( [Parameter( Mandatory=$True, Position=0, ValueFromPipeLine=$true )] [Alias(“String”)] [String]$PlainTextString, [Parameter( Mandatory=$True, Position=1 )] [Alias(“Key”)] [byte[]]$EncryptionKey ) Try{ $secureString = Convertto-SecureString $PlainTextString -AsPlainText…

  • Retreive passwords through GPO/GPP with powershell.

    There is a known vulnerability in windows where all passwords stored in Group policy preferences are encrypted with a public AES key (link to msdn). In this post we will go through how to get all the usernames and passwords from group policies in the minimum amount of time with maximum amount of data so we…

  • Counting in roman

    1 to 100 looks like this I, II, III, IV, V, VI, VII, VIII, VIV, X, XI, XII, XIII, XIV, XV, XVI, XVII, XVIII, XVIV, XX, XXI, XXII, XXIII, XXIV, XXV, XXVI, XXVII, XXVIII, XXVIV, XXX, XXXI, XXXII, XXXIII, XXXIV, XXXV, XXXVI, XXXVII, XXXVIII, XXXVIV, XC, XCI, XCII, XCIII, XCIV, XCV, XCVI, XCVII, XCVIII, XCVIV,…

  • Threaded GUI module

    Function Invoke-GUI { [cmdletbinding()] Param ( [Parameter(Mandatory=$True,ParameterSetName=”File”)] [String]$File, [Parameter(Mandatory=$True,ParameterSetName=”XAML”)] [XML]$XAML, [Parameter(Mandatory=$False)] [ScriptBlock]$OnTick = {}, [Parameter(Mandatory=$False)] [ScriptBlock]$InitializationScript = {}, [Parameter(Mandatory=$False)] [TimeSpan]$TimerInterval = “0:0:1.00”, [Parameter(Mandatory=$False)] [String]$LogFile ) If($LogFile){ $time = get-date -Format “yyyy-MM-dd HH:mm:ss” “$Time | Starting GUI script” | Out-File $LogFile -Append } $Script:Code = [hashtable]::Synchronized(@{}) $Code.TimerInterval = $TimerInterval $Code.OnTick = $OnTick $Code.InitializationScript = $InitializationScript $Code.ParameterSet…

  • Microsoft hotfix indexer and browser

    A while back I made a quick hotfix indexer script and database browser. These were not too great but had sufficient functionality for the time. Now that I have expanded on functionality I want to write this as a single post. Any Microsoft enterprise technician could see the value in having a list like this.…

  • Project: 3D Printer from scratch. Part 5 – Trial and error. And finally success!

    With all the mechanical parts assembled all that is left is firmware calibration – or so we thought. With all basic calibration done we noticed on prints that the X and Y axises were shifting. as shown below. Looking around and asking on communities this seems often to be due to when the stepper motors…

  • Project: 3D Printer from scratch. Part 4 – Assembly

    With all the parts delivered it was time to assemble. I’m not going to go through the whole build process. But it consisted of loads of screwing around (pun intended) and It’s not the prettiest build but i honestly don’t care about looks. It’s function I’m after. To make a long story short here are…

  • Hotfix browser

    #Requires -version 2 [CmdletBinding()] Param($min,$max) Begin{ $MyPath = Split-Path $MyInvocation.MyCommand.path -Parent Function SaveFileDialog{ Param( [Parameter(Mandatory=$True)] $Filetype ) [Void][Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog $SaveFileDialog.Filter = “$Filetype files (*.$Filetype)|*.$Filetype|All files (*.*)|*.*” $status = $SaveFileDialog.ShowDialog() If($status -eq “Cancel”){$Return = $status} Else{$Return = $SaveFileDialog.FileName} $SaveFileDialog.Dispose() Return $Return } Function Call-Form{ [reflection.assembly]::loadwithpartialname(“System.Windows.Forms”) | Out-Null [reflection.assembly]::loadwithpartialname(“System.Drawing”) | Out-Null $EditMode = $False…

  • Index all microsoft hotfixes

    Microsoft has a crappy hotfix index mechanism. I want to change this, and I’ve done this by indexing all support.microsoft articles myself. To do this you need a SQL server with the following table configuration Then you run the indexer script. It goes through all hotfixes inefficiently but gets the job done. All support.microsoft.com/kb pages…

  • Project: 3D Printer from scratch. Part 3 – Electronics, issues and blowing fuses

    The last parts were delivered from ebay on the 3rd of march. This took a bit longer than usual as I managed to order during the chinese new year. With all the parts at hand i decided to start building, while the paint on the frame dries I started working on the electronics. I converted…

  • Project: 3D printer from scratch. Part 2 – Printed parts delivery

    Update! I got a box yesterday with some mysterious contents. Opening it revealed the table of contents, delivery took exactly one week. I’m very pleased, this is the exact ebay item i bought Since images can tell the story better than I can this post will be mostly  pictures. All included parts scattered on the…

  • Project: 3D printer from scratch. Part 1 – The Shoppingcart.

    I’ve always wanted a 3D printer, but the pricetag has been so high that I’ve gotten discouraged in the past. However with the increasing community support of open sourced 3D printers the accessibility and price has dropped significantly if you’re willing to do some manual work. As this is not an easy task to build…

  • Solve sudoku – WIP!

    [CmdletBinding()] Param() Process{ # Initial process. Clear all grids with hints. $Hash1 = 1 # Set Datahash 1 and 2 to different values. $Hash2 = 0 While($Hash1 -notmatch $Hash2){ $Hash1 = (1..9 | ForEach-Object{($Data | Where-Object{$_.”ID”}).$_}).count Process-Sudoku $Hash2 = (1..9 | ForEach-Object{($Data | Where-Object{$_.”ID”}).$_}).count } } Begin{ # $MyPath = Split-Path $MyInvocation.MyCommand.path -Parent $Data =…

  • Find primes, the proper way

    I noticed that the earlier way to find primes is really fast for small numbers, but it is really really slow for number >5000 To shorten this, and provide a proper track of what primes are found as well as looping endlessly I’ve created this thing below. Place it as prime.ps1 in a folder with…