Skip to content

Instantly share code, notes, and snippets.

View Windos's full-sized avatar

Josh King Windos

View GitHub Profile
@Windos
Windos / rtpsug-toast-demo.ps1
Created May 4, 2023 01:23
RTPSUG Actionable Toast Notifications in Windows PowerShell
# Icons care of Wikimedia Commons
# https://commons.wikimedia.org/wiki/File:Circle-icons-chat.svg
# https://commons.wikimedia.org/wiki/File:Pictogram_reply_soft_green_wbg.svg
$ChatIcon = 'C:\Demos\Circle-icons-chat.svg.png'
$ReplyIcon = 'C:\Demos\Pictogram_reply_soft_green_wbg.svg.png'
# Download from here: https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.Notifications/
@Windos
Windos / keybase.md
Created May 11, 2021 15:24
keybase.md

Keybase proof

I hereby claim:

  • I am windos on github.
  • I am windosnz (https://keybase.io/windosnz) on keybase.
  • I have a public key ASAfWmAOfO_MviM60G-tNVJBpgl43PTNPJlsiFzi2IyYtQo

To claim this, I am signing this object:

@Windos
Windos / ToastEvents-PowerShell5.1.ps1
Created March 17, 2021 11:36
Rough mock-up of actionable toasts in PowerShell 5.1
Add-Type -Path 'C:\temp\microsoft.toolkit.uwp.notifications.7.0.0\lib\net461\Microsoft.Toolkit.Uwp.Notifications.dll'
$CompatMgr = [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]
Register-ObjectEvent -InputObject $CompatMgr -EventName OnActivated -Action {
if ($Event.SourceArgs.Argument -eq 'SubmitButton') {
switch ($Event.SourceArgs.UserInput.Value) {
Item1 {
$Text1 = 'GIF: Picard Facepalm'
$ImagePath = 'C:\Demos\Gifs\facepalm.gif'
}
@Windos
Windos / TopWords.ps1
Created February 2, 2021 20:10
RTPSUG Meetup Practice Challenge
# See challenge prompt here: https://jdhitsolutions.com/blog/powershell/8107/scripting-challenge-meetup/
$HelpAbout = help about_Splatting
$Words = $HelpAbout -replace '_', ' ' -split '\b' | Where-Object {$_ -match '\w+' -and $_ -ne 'the'}
$GroupedWords = $Words | Group-Object | Sort-Object -Property Count -Descending
[PSCustomObject] @{
Name = $HelpAbout.Name
WordCount = $Words.Count
# May need to update the "Chrome Driver", run this from the module path (it's not an imported command)
# .\Selenium-Binary-Updater.ps1
# Start the driver (this is headless so you shouldn't see anything. Do this once.
$StartUri = 'https://www.twitch.tv/'
$Driver = Start-SeChrome -Arguments "incognito" -HideVersionHint -StartURL $StartUri -Quiet -Headless
# Repeat this part for each profile
# Specify the user you're looking for
$UserName = 'WindosNZ'
# Install-Module BurntToast
$Text1 = New-BTText -Content 'Help!'
$Text2 = New-BTText -Content "Please send help."
$Audio1 = New-BTAudio -Source 'ms-winsoundevent:Notification.Mail'
# Point the source at a gif that exists...
$HeroImage = New-BTImage -Source 'C:\Temp\Help.gif' -HeroImage
$Binding1 = New-BTBinding -Children $Text1, $Text2 -AppLogoOverride $Image1 -HeroImage $HeroImage
@Windos
Windos / Restore-SPO-Files.ps1
Created May 26, 2020 00:17
Deleted a *very* large directory in SharePoint Online? Restore the files en masse with the SPO PnP Module
# Needs the SharePoint Online PnP module, install if haven't got it already:
# Install-Module SharePointPnPPowerShellOnline
$Uri = 'https://tenant.sharepoint.com/sites/Common'
Connect-PnPOnline -Url $Uri -UseWebLogin
$DeletedAt = (Get-Date -Day 24 -Month 05 -Hour 0 -Minute 0 -Second 0)
$DeletedBy = 'first.last@tenant.com'
@Windos
Windos / Toast-RTEvent-Example.ps1
Created March 31, 2020 07:16
Example of trying to register a Windows RT event via PowerShell, specifically here we're looking at events on Toast Notifications
$XmlString = @"
<toast>
<visual>
<binding template="ToastGeneric">
<text>Default Notification</text>
<image src="C:\Program Files\PowerShell\7\assets\Powershell_av_colors.ico" placement="appLogoOverride" />
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.Default" />
</toast>
@Windos
Windos / RTPSUG-Null.ps1
Last active March 5, 2020 02:28
Null operators demo for RTPSUG 2020-03-04
break
#region Null Coalescing Operator (??)
# Returns value on the left if it's not null
# Otherwise the right had side is evaluated and returned
$Left ?? $Right
@Windos
Windos / MembershipMatrix.ps1
Created December 11, 2019 09:33
Group Membership Matrix Example
$Users = Get-ADUser -Filter 'Enabled -eq $true'
$GroupNames = (Get-ADGroup -Filter * |
Where-Object {$_.DistinguishedName -notlike '*CN=Builtin,*'}).Name
$Report = foreach ($User in $Users) {
$Groups = Get-ADPrincipalGroupMembership -Identity $User.DistinguishedName
$ReportProp = [Ordered] @{
'Name' = $User.DisplayName
'Username' = $User.SamAccountName