代码之家  ›  专栏  ›  技术社区  ›  Jonesome Reinstate Monica

如何向用户发送通知或消息?

  •  0
  • Jonesome Reinstate Monica  · 技术社区  · 4 年前

    我有一个脚本,它在当前用户空间中运行,但在后台,永久最小化。

    它需要通过系统托盘或Windows发送通知。UI。通知机制(或其他类似的机制)。

    在Win11/Win10的powershell中是如何做到这一点的?

    1 回复  |  直到 4 年前
        1
  •  4
  •   DocZerø    4 年前

    我认为 BurntToast 模块是您要查找的内容:

    用于显示Windows 10和Windows Server 2019 Toast通知的PowerShell模块

    以下是自述文件中的一个简单示例:

    New-BurntToastNotification `
        -AppLogo C:\smile.jpg `
        -Text "Don't forget to smile!",
         'Your script ran successfully, celebrate!'
    

    结果:

    Toast

        2
  •  3
  •   Almighty    4 年前
    # this can be a manual input array of users as well
    $users = ((Get-WMIObject -ClassName Win32_ComputerSystem).Username).Split('\')[1]
    $WhatToSend = Read-Host "What do you want the message to be"
    foreach ($user in $users){
        & msg $user $WhatToSend
    }
    
    #if you want to send the message to all users then use a wildcard
    msg * $WhatToSend
    
    推荐文章