Skip to content

Instantly share code, notes, and snippets.

View Windos's full-sized avatar

Josh King Windos

View GitHub Profile
@Windos
Windos / SplitPaths to Excel.ps1
Created October 9, 2019 22:56
It's not pretty, or fast, but it'll work!
$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
$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
$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'
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
$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
# 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>
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 January 10, 2019 05:18
XML dump for inclusion in blog post
<?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>
function Get-OrphanedMailbox {
$ExSplat = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = 'http://exchange.example.com/powershell'
Authentication = 'Kerberos'
}
$ExSession = New-PSSession @ExSplat
Import-PSSession -Session $ExSession *>$null
### GetMailAutoReply.ps1
<#
.SYNOPSIS
Gets a users current auto reply message and state.
#>
param
(
[Parameter(Mandatory = $true,