We have a build which requires us to replace files to a newer version on 
remote computers and the requirement is the script needs to take screenshot 
of the folder for validation.
We have built our ps script and it does what is needed when executed 
outisde of Jenkins but not when scheduled with Jenkins, here is the 
screenshot portion of the script:
function ScreenshotFolder 
{














































*# Get the list of servers$servers = Get-Content 
"C:\tmp\script\updated\computers.txt"  # Foreach loop to go to each server 
and take the screenshot  foreach ($server in $servers)  {        # Invoke 
the path of Application    $FolderWindows = Start 
"\\$server\C$\Temp\Application" -WindowStyle Maximized    # Pause the 
script for 2 seconds so that the invoked path Windows will stay for 2 
seconds before screencapture    Start-Sleep -s 2    # Provide the unique 
name for the .bmp file    $File = join-path -path 
"C:\tmp\script\updated\Logs" -childpath $($server + "-screenshot" + 
".bmp")    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)     Write-Output "Screenshot saved to:"    
Write-Output $File    # Close each folder windows so that it would capture 
each windows at a time    $CloseWindows = (New-Object -comObject 
Shell.Application).Windows() |? { $_.FullName -ne $null} | ? { 
$_.FullName.toLower().Endswith('\explorer.exe') }     $CloseWindows | % {  
$_.Quit()}}}*

Jenkins service us configured to be running using service account which has 
access to the remote servers. Console output:











*Start-Process : This command cannot be run due to the error: Server 
execution failed.At 
C:\Users\ctoCITRIX4win09\AppData\Local\Temp\hudson7511677238111411019.ps1:385 
char:22+     $FolderWindows = Start "\\$server\C$\Temp\Application" 
-WindowStyle Maximized+                      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + 
CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOp    
erationException    + FullyQualifiedErrorId : 
InvalidOperationException,Microsoft.PowerShell.C    
ommands.StartProcessCommand*Any suggestions to achieve this screenshot 
function using script on Jenkins? We're ok to explore other tools as well.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/d2a0f96b-c413-49ef-b588-41693407fb35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to