Skip to content

Instantly share code, notes, and snippets.

@khazeamo
khazeamo / getQwinstaSessions.ps1
Last active October 21, 2024 14:41
Output of qwinsta.exe varies depending on OS language. Column length seems to vary between OS versions. This is a try to reliably convert the text output of qwinsta.exe.
# Get text output of qwinsta
$qwinstaOutput = &qwinsta.exe
# Column definitions (in the order as they appear in the output of qwinsta)
# Name --> Name of the property in the output object
# Start --> Should always be 0 and is detected automatically later in the script (varies depending on the output language)
# Length -eq 0 --> Column is left aligned with variable length (detected later in the script)
# Length -gt 0 --> Column is right aligned with fixed length
$columnInfo = @(
[PSCustomObject]@{
#Requires -Modules Microsoft.Graph.Authentication, Microsoft.Graph.Applications
[CmdletBinding()]
param (
# Name, application ID or object ID of the managed identity
[Parameter(Mandatory = $true)]
[string]
$ManagedIdentity,
# Name or ID of the Graph API permission (application role)
@khazeamo
khazeamo / showToastNotification.ps1
Last active August 13, 2018 10:54
PowerShell Toast Notification
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
#Gets the Template XML so we can manipulate the values
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
[xml]$ToastTemplate = @"
<toast duration="long" launch="app-defined-string">