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

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


reCaptcha の認証期間が終了しました。ページを再読み込みしてください。

関連記事

no image

PowerShellで現在の文字セットを確認&変更する方法

確認環境 PSVersion 5.1.18362.1171 文字セットを確認 以下のようにchcpコマンドを使用すると、現在のコンソールで設定されている文字セットを表す数値である、コードページが確認で …

no image

PowerShellの比較演算子一覧

確認環境 PSVersion 5.1.18362.1110 比較演算子 演算子他言語の演算子説明-eq==等しい(equal)-ne!=等しくない(not equal)-gt>より大きい(Greate …

no image

PowerShellで相対パスを絶対パスに変換する

こんにちは、今日はPowerShellで相対パスを絶対パスに変換する方法についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 相対パスを絶対パスに変換する PS C: …

no image

PowerShellで関数を定義する方法

定義方法 引数なし 引数なしの関数は以下のように定義します。中かっこの中に任意の処理を記述します。 function Test-Func { Write-Host Hello World } 実行する …

no image

PowerShellで右寄せ左寄せする方法

こんにちは、今日はPowerShellで右寄せ左寄せする方法についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 右寄せ "{0,5}" -f 1 …