Skip to content

Instantly share code, notes, and snippets.

View 1RedOne's full-sized avatar

Stephen Owen 1RedOne

View GitHub Profile
@1RedOne
1RedOne / Lottery.Md
Last active May 13, 2025 22:37
Why you don't want to win the lottery
@1RedOne
1RedOne / DataGridsAreFun.ps1
Created September 20, 2018 03:03
WPF Example of using and populating a DataGrid with objects in PowerShell
#Sample for this question on SO https://stackoverflow.com/questions/52405852/link-wpf-xaml-to-datagrid-in-powershell?sem=2
$inputXML = @"
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
@1RedOne
1RedOne / ReadMe.md
Last active August 16, 2018 14:57
Parsing Malformed HTML via SQL

First off the source HTML has a lot of issues, as we can see here:

'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE type=text/css> P, UL, OL, DL, DIR, MENU, PRE { margin: 0 auto;}</STYLE>
<META name=GENERATOR content="MSHTML 11.00.10586.35"></HEAD>

<BODY leftMargin=1 topMargin=1 rightMargin=1>
@1RedOne
1RedOne / AddSurNametoUpper.ps1
Last active August 8, 2018 02:21
A scratch of swapping a dash for a period in AD>
if ($user.Surname){
"$user has a surname"
$newSurname = $user.Surname.ToUpper()
"changing to $newSurname"
$user | Set-ADUser -Surname $newSurname -WhatIf
}
@1RedOne
1RedOne / Sample.ps1
Created July 2, 2018 20:14
GUI Post 2 Final XAML
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication2"
mc:Ignorable="d"
Title="FoxDeploy Awesome Tool" Height="416.794" Width="598.474" Topmost="True">
<Grid Margin="0,0,45,0">
<Image x:Name="image" HorizontalAlignment="Left" Height="100" Margin="24,28,0,0" VerticalAlignment="Top" Width="100" Source="C:\Users\Stephen\Dropbox\Docs\blog\foxdeploy favicon.png"/>
@1RedOne
1RedOne / Sample.ps1
Last active July 2, 2018 20:14
GUI Post II 3/4 XAML Sample
<GridView>
<GridViewColumn Header="Drive Letter" DisplayMemberBinding ="{Binding 'Drive Letter'}" Width="120"/>
<GridViewColumn Header="Drive Label" DisplayMemberBinding ="{Binding 'Drive Label'}" Width="120"/>
<GridViewColumn Header="Size(MB)" DisplayMemberBinding ="{Binding Size(MB)}" Width="120"/>
<GridViewColumn Header="FreeSpace%" DisplayMemberBinding ="{Binding FreeSpace%}" Width="120"/>
</GridView>
@1RedOne
1RedOne / Sample.ps1
Created July 2, 2018 19:51
GUI Post II Mid-way Code Sample
$inputXML = @"
<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApplication2" mc:Ignorable="d" Title="FoxDeploy Awesome Tool" Height="416.794" Width="598.474" Topmost="True">
<Grid Margin="0,0,45,0">
<Image x:Name="image" HorizontalAlignment="Left" Height="100" Margin="24,28,0,0" VerticalAlignment="Top" Width="100" Source="C:\Users\Stephen\Dropbox\Docs\blog\foxdeploy favicon.png"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Height="100" Margin="174,28,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="282" FontSize="16"><Run Text="Use this tool to find out all sorts of useful disk information, and also to get rich input from your scripts and tools"/><InlineUIContainer>
<TextBlock x
@1RedOne
1RedOne / GUI Blog Post XAML Snippet.ps1
Last active July 2, 2018 19:46
PowerShell XAML Sample
<Window x:Class="FoxDeploy.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Azure"
mc:Ignorable="d"
Title="FoxDeploy Awesome GUI" Height="524.256" Width="332.076">
<Grid Margin="0,0,45,0">
<Image x:Name="image" HorizontalAlignment="Left" Height="100" Margin="24,28,0,0" VerticalAlignment="Top" Width="100" Source="C:\Users\Stephen\Dropbox\Docs\blog\foxdeploy favicon.png"/>
@1RedOne
1RedOne / XAML_Snippet.ps1
Created July 2, 2018 19:38
PowerShell XAML GUI Scaffold, with better error handling
#Your XAML goes here :)
$inputXML = @"
<Window x:Class="Azure.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Azure"
mc:Ignorable="d"
Title="FoxDeploy Awesome GUI" Height="524.256" Width="332.076">
@1RedOne
1RedOne / UserControl Demo.ps1
Last active May 31, 2018 13:54
UserControl Example
#This short demo demonstrates how to use a custom user control within your code
#First, we define our base form as we traditionally do, and load it into memory
$inputXML = @"
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication2"