3テラバイト

プログラム関連備忘録サイト。主にゲーム。

PowerShell

PowerShellでトースト通知を送る

投稿日:2021年1月30日 更新日:

確認環境

PSVersion 5.1.18362.1110

トースト通知を送る

[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'

$template = @"
    <toast>
    </toast>
"@

$output = New-Object Windows.Data.Xml.Dom.XmlDocument
$output.LoadXml($template)

[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app).show($output)

変数$templateにトースト通知に表示する内容をXML形式で記述します。

このファイルを実行で内容が空のトースト通知が送られます。

リンク

ToastNotificationManager.CreateToastNotifier Method (Windows.UI.Notifications) – Windows UWP applications | Microsoft Docs
https://docs.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotificationmanager.createtoastnotifier?view=winrt-19041

ToastNotification(XmlDocument) Constructor (Windows.UI.Notifications) – Windows UWP applications | Microsoft Docs
https://docs.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification.-ctor?view=winrt-19041

ToastNotifier.Show(ToastNotification) Method (Windows.UI.Notifications) – Windows UWP applications | Microsoft Docs
https://docs.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotifier.show?view=winrt-19041

-PowerShell


comment

メールアドレスが公開されることはありません。

関連記事

no image

PowerShellでCSVファイルを出力する

こんにちは、今日はPowerShellでCSVファイルを出力する方法についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 CSVファイルを出力する CSVファイルを出 …

no image

PowerShellでコマンドのあるパスを取得する

確認環境 PowerShell 5.1 コマンドのパスを取得する Get-Commandコマンドレットにコマンド名を渡すと、Source列にてそのコマンドのパスが確認できます。 PS C:\Users …

no image

PowerShellでアイテムを作成するコマンドレットNew-Itemの使い方

こんにちは、今日はPowerShellでファイルやフォルダ等のアイテムを作成するコマンドレットNew-Itemの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362.11 …

no image

PowerShellでロード済のアセンブリ一覧を取得する

以下のように現在のアプリケーション ドメインを取得し、そのドメインで読み込まれているアセンブリをGetAssemblies関数で取得します。 PS C:\Users\santerabyte> & …

no image

TCP接続を確認できるPowerShellコマンドレットGet-NetTCPConnectionの使い方

すべての接続 何も引数を指定せずに実行すると、すべての接続が表示されます。 Get-NetTCPConnection 項目絞り込み LocalAddress Get-NetTCPConnection …