
Instalé PS Scripts en mi máquina virtual. Mi VM está conectada a una cuenta de dominio. Tengo una cuenta de servicio proporcionada. En este momento mi script se ejecuta manualmente. Pero cuando estoy esperando el momento en que configuré el script, no funciona. Estoy usando el servidor Windows 2016.
Secuencia de comandos de Power Shell
$path = "C:\Users\svaccount\Desktop\STAT1\"
$fileName = "STAT1_"
$date = Get-Date -Format MMddyyyhhmmss
$file = $path + $filename +
$date + ".jpeg"
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
# Gather Screen resolution information
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width = $Screen.Width
$Height = $Screen.Height
$Left = $Screen.Left
$Top = $Screen.Top
# Create bitmap using the top-left and bottom-right bounds
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
# Create Graphics object
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
# Capture screen
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
# Save to file
$bitmap.Save($File)
Mi configuración en Task.
PESTAÑA GENERAL -opciones de seguridad .usuario de cuenta: (cuenta de servicio) .Selecciono Ejecutar solo cuando el usuario inicia sesión. .Ejecución seleccionada con los privilegios más altos .configure para: servidor de Windows 2016 PESTAÑA DE GATILLO Comience la tarea: según un cronograma Configuración: Diaria, Repetida cada 1 día Configuración avanzada: seleccionado Repetir tarea cada: 5 minutos durante 1 día HABILITAR está seleccionado PESTAÑA ACCIÓN acción: iniciar un programa Ajustes: .Programa/script: powershell.exe .agregar argumentos (opcional): -estilo de ventana oculto "C:\POGI.ps1" PESTAÑA CONDICIONES .Seleccionó reactivar la computadora para ejecutar esta tarea. PESTAÑA DE CONFIGURACIÓN .Seleccionado permitir que la tarea se ejecute bajo demanda
Encuentro una línea para depurar mi script: no sé si esto ayuda
**********************
Windows PowerShell transcript start
Start time: 20181129151208
Username: OSISOFT\svaccount
RunAs User: OSISOFT\svaccount
Machine: PI-WBS (Microsoft Windows NT 10.0.14393.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 19732
PSVersion: 5.1.14393.206
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.206
BuildVersion: 10.0.14393.206
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is c:\temp\debug.log
**********************
Windows PowerShell transcript end
End time: 20181129151209
**********************
Agradezco tu ayuda con esto.
¡Gracias!