Skip to content

Instantly share code, notes, and snippets.

View lazywinadmin's full-sized avatar

François-Xavier Cat lazywinadmin

View GitHub Profile
@lazywinadmin
lazywinadmin / FrPSUG-Parse_survey_sondage.ps1
Last active October 28, 2018 04:45
French PowerShell User Group - Parse the survey on topics from 2017/09 sent to all members
# Load file
$Content = import-csv 'responses.csv' -Header time,VotreNiveau,HeureParfaite,NiveauDesPresentations,Sujet |
select -Skip 1 |
select -prop VotreNiveau,HeureParfaite,NiveauDesPresentations,Sujet
# Create some arrays
$allHeureParfaitevalues=@()
$allSujetvalues=@()
# Retrieve properties (questions) and foreach...
@lazywinadmin
lazywinadmin / Powershell_HTTP_Server.MD
Created August 4, 2018 01:29 — forked from jakobii/HTTPServer.ps1
A Basic Powershell Webserver

This is a super SIMPLE example of how to create a very basic powershell webserver

# Http Server
$http = [System.Net.HttpListener]::new() 

# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
#https://communary.net/2015/01/12/quick-tip-determine-if-input-comes-from-the-pipeline-or-not/
function Invoke-Test {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
[PSObject[]] $InputObject,
[Parameter()]
[string] $SecondParam
)
$MeetupSecretKey = '<My API Key>'
# POST
Invoke-RestMethod -Uri "https://api.meetup.com/2/events?key=$script:MeetupSecretKey&sign=true&group_urlname=FrenchPSUG&name=testevent" -Method post
#Invoke-RestMethod : The remote server returned an error: (405) Method Not Allowed.
# Using a Session
Invoke-RestMethod -Uri "https://api.meetup.com/2/events?key=$script:MeetupSecretKey&sign=true&group_urlname=FrenchPSUG&name=testevent" -SessionVariable aa
#Works
# Signed_url is available in $aa.meta.signed_url
Invoke-RestMethod -Uri "https://api.meetup.com/2/events?key=$script:MeetupSecretKey&sign=true&group_urlname=FrenchPSUG&name=testevent" -Method post -WebSession $aa
function Get-DomainComputer {
[CmdletBinding()]
PARAM(
[Parameter(ValueFromPipelineByPropertyName=$true,
ValueFromPipeline=$true)]
[Alias("Computer")]
[String[]]$ComputerName,
[Alias("ResultLimit","Limit")]
[int]$SizeLimit='100',
@lazywinadmin
lazywinadmin / Get-OlympicMedal.ps1
Created February 16, 2018 03:04
Get Olympics 2018 medal ranking per country
function Get-HTMLTable
{
param (
[Parameter(Mandatory = $true)]
[Microsoft.PowerShell.Commands.HtmlWebResponseObject]$WebRequest,
[Parameter(Mandatory = $true)]
[int]$TableNumber
)
@lazywinadmin
lazywinadmin / HOWTO.md
Created January 13, 2018 16:46 — forked from cvan/HOWTO.md
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@lazywinadmin
lazywinadmin / ipinfo.ps1
Created April 22, 2017 18:29
Retrieve IP Information from your current public ip address
irm http://ipinfo.io
<#
ip : 100.111.122.33
hostname : Something.ebox.ca
city : Montreal
region : Quebec
country : CA
loc : 49.4667,-70.4667
org : AS1000 EBOX
@lazywinadmin
lazywinadmin / Pipeline.ps1
Created February 24, 2017 17:03
How does BEGIN PROCESS END Blocks work in the pipeline
function A
{
[CmdletBinding()]
Param
(
[parameter(ValueFromPipeline=$true)]
$MyParam
)
Begin