Skip to content

Instantly share code, notes, and snippets.

Joshua King Windos

Block or report user

Report or block Windos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Windos
Windos / SplitPaths to Excel.ps1
Created Oct 9, 2019
It's not pretty, or fast, but it'll work!
View SplitPaths to Excel.ps1
$Files = Get-ChildItem -Path C:\Temp -Recurse -File
$SplitFiles = @()
foreach ($File in $Files) {
$SplitFiles += ,$File.FullName.Split('\')
}
$NumColumns = ($SplitFiles | Measure-Object -Maximum -Property Count).Maximum
View File-Per-Directory.ps1
$Files = Get-ChildItem -Path 'C:\Temp' -Filter "*.tsv" -Recurse
$Directories = $Files | Group-Object -Property 'DirectoryName'
foreach ($Directory in $Directories) {
$Outfile = Join-Path -Path $Directory.Name -ChildPath '\HTML-File-Name.html'
# Start your HTML file here, add CSS or headings.
foreach ($File in $Directory.Group) {
Import-Csv -Delimiter "`t" -Path $File.FillName | ConvertTo-Html | Out-File -FilePath $Outfile -Append
View ToastButton.ps1
$Time = Get-Date -Format t
$Text1 = New-BTText -Content 'Report Generated'
$Text2 = New-BTText -Content "Completed at $Time"
$Audio1 = New-BTAudio -Source 'ms-winsoundevent:Notification.IM'
$Binding1 = New-BTBinding -Children $Text1, $Text2
$Visual1 = New-BTVisual -BindingGeneric $Binding1
$Button1 = New-BTButton -Content 'Open Report' -Arguments 'C:\Fake\Report\Location.csv'
View AzureAD-DisablePlans-ExistingUsers.ps1
Import-Module AzureAD
Connect-AzureAD
# Need to know the License Sku and Service Plan
# It is possible to get this from the module itself
Get-AzureADSubscribedSku | select SkuId, SkuPartNumber, ServicePlans
# May be easier to get online: https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference
View BlogTweet-Azure.ps1
$Uri = 'https://king.geek.nz/rss/'
$Posts = [System.Collections.ArrayList]::new()
$PageNumber = 1
$More = $true
while ($More) {
try {
$Page = Invoke-RestMethod -Uri "$Uri$PageNumber" -ErrorAction Stop
} catch {
$Page = $null
View toast-click.xml
# For cliackable toast, the toast element needs an activationtype set to protocol and a "launch" argument set to the thing to launch
# (be that a website or file, etc.)
# Example with BurntToast: https://king.geek.nz/2017/05/08/crouton-clickable/
<?xml version="1.0" encoding="utf-8"?>
<toast activationType="protocol" launch="https://google.com">
<visual>
<binding template="ToastGeneric">
<text>Google!</text>
View ToastEvents.ps1
Import-Module BurntToast
$Text1 = New-BTText -Content 'This is a test'
$Text2 = New-BTText -Content 'This more testing'
$AppLogo = New-BTImage -Source 'https://raw.githubusercontent.com/Windos/BurntToast/master/Media/BurntToast.png' -Crop Circle -AppLogoOverride
$Binding1 = New-BTBinding -Children $Text1, $Text2 -AppLogoOverride $AppLogo
$Visual1 = New-BTVisual -BindingGeneric $Binding1
$Content = New-BTContent -Visual $Visual1
$AppId = "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe"
@Windos
Windos / RemoteToast.xml
Created Jan 10, 2019
XML dump for inclusion in blog post
View RemoteToast.xml
<?xml version="1.0" encoding="utf-8"?><toast><visual><binding template="ToastGeneric"><text>No Time For Questions</text><text>All servers are being shut down in __WARNTIME__, save your work!</text></binding></visual><audio src="ms-winsoundevent:Notification.Looping.Alarm" /></toast>
View Get-OrphanedMailbox.ps1
function Get-OrphanedMailbox {
$ExSplat = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = 'http://exchange.example.com/powershell'
Authentication = 'Kerberos'
}
$ExSession = New-PSSession @ExSplat
Import-PSSession -Session $ExSession *>$null
View WebJEA-Exchange-AutoReply.ps1
### GetMailAutoReply.ps1
<#
.SYNOPSIS
Gets a users current auto reply message and state.
#>
param
(
[Parameter(Mandatory = $true,
You can’t perform that action at this time.