Posts

The next chapter... or rather next page. :)

Dusting off the blog with an updated description: my journey from the monad [1] to the monde beyond. See what I did there? 😁 No solid promise but I hope to soon share more about my career journey. A journey started from an IT Pro in a public section company to an engineer at Amazon and Google. [1] PowerShell's Monad manifesto

Testing Self-Contained PowerShell Script with Pester

In this post, I am going to share how to unit testing helper functions in a self-contained PowerShell script. I have the opportunity to write  AWS Systems Manager Command Documents that are actually PowerShell scripts. The SSM documents (PowerShell scripts) are then executed by on triggers so I rely less on the Windows Scheduled Task. This is one of the cases that I prefer managing code in a self-contained PowerShell script rather than modules. (Another one is PowerShell Lambda). Self-contained scripts are the scripts that contain helper functions and business logic codes in the same file. When evaluating the dependency management effort versus delivering results, I'm really less inclined to use config management tooling to configure my Windows worker server. Anyway, that's another topic for another post. <TL;DR> In the Pester test file, use Powershell Abstract Syntax Tree (AST) to parse out the helper functions from the main PowerShell script. Then, save each functio

PowerShell Universal Dashboard and AWS Elastic Beanstalk

Image
PowerShell Universal Dashboard and AWS Elastic Beanstalk PowerShell UD is a powerful PowerShell frontend framework and I highly recommend you to try it out. I played with PowerShell Universal Dashboard (UD) when it was released in beta by Adam Driscoll. At that time I hosted a dashboard on Raspberry Pi to show some sensor data. I really like UD as it enables PowerShell developer to create a beautiful, interactive and usable webpage with just a few lines of PowerShell code. Fast forward. A few days ago while showering, I was wondering how would one run UD using AWS, and most importantly without managing the server. (Shower is one of the best activities to inspire innovation, btw. 😎) I won't bore you with the attempts I tried. In the end, I decided to use AWS Elastic Beanstalk (Beanstalk) and it worked nicely. In this post, I will share with you about how to run PowerShell Universal Dashboard (UD) with AWS Elastic Beanstalk (Beanstalk). Beanstalk is an orchestration service

Elementary school math with Kids... using PowerShell

Image
I attended a parent-teacher conference this week in my kids' school. Interesting enough the school now evaluates students' math level with an online services, which claimed to provide real-time feedback to teacher. Needless to say, kids have areas to improve. I came home that night and decided to play some math games with my kids. I started my saying random numbers and challenged kids to add or subtract those numbers. Like... "Let me challenge you with this question.... 17 + 12?" Soon, I started to repeat numbers and also forgot about the number I just said! 🤦‍♂️ So... I whispered to myself, there is nothing can't be done with a little bit determination and PowerShell. I started off by using the Get-Random to get random numbers between 1 and 30. Then decided to have PowerShell just generate the questions for me. PS C:\Users\l> Get-Random -Minimum 1 -Maximum 30 7 PS C:\Users\l> Write-Host "$(Get-Random -Minimum 1 -Maximum 30) + $(Get-Random -Min

When TLS 1.2 breaks Invoke-Webrequest

Image
Update[7/16/18]: Marc R Kellerman kindly shared his approach on twitter with me today: [Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType].GetEnumValues() It works as we can pass an array of values to the Net.ServicePointManager.  I think this is nicely done! Thank you so much Marc!  Head over to  Marc's twitter and blog  for more good information! With more websites moving to TLS 1.2 only, I find using Invoke-WebRequest from Windows PowerShell becomes less reliable because Windows PowerShell's defaults to using Ssl3 and TLS1.0. In this post I am going to share how I worked around the challenge in Windows PowerShell. Very importantly, if you can use PowerShell Core 6 for Invoke-WebRequest, do it. The cmdlet is much improved in PowerShell Core 6 thanks to Mark Karus . So over the past weekend, I was learning about English and was experimenting to parse the Princeton university's WordNet site  with PowerShell. However, I got this bleedin

Mini steps to learning data structure and algorithm with PowerShell

I have been reading and learning on the data structure and a little bit of algorithm since PowerShell Summit 2018. I chatted with phenomenal folks at the Summit and that experience really deepen my attention to PowerShell's language implementation. Now I am so curious on why hash table is preferable, why list is more recommended than array and why performance varies....so many why. I decided to build my Computer Science fundamentals to help answering some of these questions. The first few chapters of the data structure book I am reading talks about the sequential list, linked list, double linked list, circular list, stack, and queue. Amazing to see how the great minds in Computer Science solved hard challenges like finding the correct value in the memory. Today, the stack section talked about the Fibonacci number . I wondered how I would calculate the series using PowerShell.... Below are my initial attempts. One using recursion and the other with iteration. Interesting that it

Quick review on my career after learning PowerShell

I have been an operator through our my IT career, clicking through the software install, user/ machine provisioning, and checking logs until I learned PowerShell. At first, I started scripting many of the repetitive tasks, and then some complex ones. They generated regular Active Directory/ file system/ Exchange reporting, scanned for cryptolocker affected files in file shares, and audited Exchange user attributes for the entire company. Things got wild after having a bunch of PowerShell scripts laying around in my local folders. Now I look back, it seems the path evolved so naturally. I needed a way to manage the PowerShell scripts and their history safely. So I started using Git. I wanted to work with others on my team and we had peer reviews. Spinning up VMs/ Cloud instances were then became bottlenecks in the workflow so configuration management and Infrastructure as code were embraced. Secret management, logging and monitoring, automated backup and recovery.... more and more w