2016-08-08 5 views
0

(원격) 사용자 입력이 필요한 원격 컴퓨터에서 팝업을 생성 할 수 있습니까? PowerShell을 사용하여 원격 컴퓨터에서 스크립트를 실행하고 해당 컴퓨터 뒤의 활성 사용자가 스크립트 실행을 허용하도록합니다. 기본 설정이 불가능합니다. 동일한 목표를 달성하는 데 사용할 수있는 간단한 타사 솔루션 (원격 사용자 컴퓨터에 설치가 필요하지 않음)이 있습니까?원격 사용자 입력

상자에서 생각해 보면 필자는 메일을 보내고받는 답장을 검색 할 때 powershell을 사용할 수는 있지만 비효율적이라고 생각합니다.

+0

예약 된 작업을 만들어 대화 형 사용자로 실행하고 즉시 시작할 수 있습니다. 나는 당신이 뭔가를 터뜨릴 수 있는지, 결코 시도하지 않았는지 확실하지 않습니다. 그렇지 않으면 로그온 한 사용자의 컨텍스트에서 실행할 항목을 얻는 것이 약간의 고통입니다. –

+0

@Chris Dent 흥미로운 옵션. 그걸 살펴볼 것입니다, 고마워요. – RockYoClock

답변

0

사실 저는 UWP의 Toast messages API를 사용하여 이와 비슷한 것을 만드는 것에 매우 가깝습니다. 단추 및 텍스트 상자 (또한 Invoke-Command를 사용하여 원격 컴퓨터에서도)로 토스트 메시지를 만들 수 있지만 입력 또는 단추에서 결과를 다시 얻는 데는 실패한 경우가 있습니다 (UWP 설명서를 살펴보면 Powershell에서는 불가능).

샘플 코드 UWP의 토스트 메시지에 대한 자세한 내용은이 버전에서 로컬 또는 원격을 실행할 수 있습니다. 버튼에 XML 콘텐츠가 포함되어 있지는 않지만 마이크로 소프트가 쓴 API 문서를 따라 가면 구현하기 쉽다.) 더 많은 행운을 누릴 수있다. (면책 조항 : 이것은 나의 첫 번째 작업 개념이고, 코드는 아직 최적화되지 않았으며, "로컬"코드에 대한 많은 중복 코드가있다. 및 "원격"버전 등) :

Function Invoke-ToastMessage 
{ 
[CmdletBinding()] 
    Param 
     (
     [string]$Message, 
     [string]$Notifier = "Administrators", 
     [string]$ComputerName = $null 
     ) 

[scriptblock]$ToastScriptRemote = { 
$Message = $args[0] 
$Notifier = $args[1] 
# XML Template 
[xml]$XmlTemplate = @" 
<toast scenario="reminder"> 
    <visual> 
    <binding template="ToastGeneric"> 
     <text>Admin Notification</text> 
     <text>$Message</text> 
    </binding> 
    </visual> 
    <actions> 
    </actions> 
</toast> 
"@ 
    # fake load the assemblies 
    [void][Windows.UI.Notifications.ToastNotification,Windows.UI.Notifications,ContentType=WindowsRuntime] 
    [void][Windows.Data.Xml.Dom.XmlDocument,Windows.Data.Xml.Dom,ContentType=WindowsRuntime] 
    $FinalXML = [Windows.Data.Xml.Dom.XmlDocument]::new() 
    $FinalXML.LoadXml($XmlTemplate.OuterXml) 
    ## create the toast 
    $Toast = [Windows.UI.Notifications.ToastNotification]::new($FinalXML) 
    ## Show the TOAST message 
    [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Notifier).show($Toast) 
    } 

[scriptblock]$ToastScriptLocal = { 
# XML Template 
[xml]$XmlTemplate = @" 
<toast scenario="reminder"> 
    <visual> 
    <binding template="ToastGeneric"> 
     <text>Admin Notification</text> 
     <text>$Message</text> 
    </binding> 
    </visual> 
    <actions> 
    </actions> 
</toast> 
"@ 
    # fake load the assemblies 
    [void][Windows.UI.Notifications.ToastNotification,Windows.UI.Notifications,ContentType=WindowsRuntime] 
    [void][Windows.Data.Xml.Dom.XmlDocument,Windows.Data.Xml.Dom,ContentType=WindowsRuntime] 
    $FinalXML = [Windows.Data.Xml.Dom.XmlDocument]::new() 
    $FinalXML.LoadXml($XmlTemplate.OuterXml) 
    ## create the toast 
    $Toast = [Windows.UI.Notifications.ToastNotification]::new($FinalXML) 
    ## Show the TOAST message 
    [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Notifier).show($Toast) 
    } 

if (![string]::IsNullOrEmpty($ComputerName)) 
    { 
     Invoke-Command -ComputerName $ComputerName -ScriptBlock $ToastScriptRemote -ArgumentList $Message,$Notifier 
    } 
    else {$ToastScriptLocal.Invoke()} 
} 
+0

UWP를 사용하여 좋은 아이디어가 있습니다. 너무 나쁘면 사용자 입력을 원격으로 반환 할 수 없습니다. 이미이 게시물을 보지 못했을 경우, 귀하의 방법을 사용하는 몇 가지 예를 발견했습니다. https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications- 적응 형 대화 형 토스트 – RockYoClock