I have a script in PowerShell. It's running from Jenkins via a PowerShell step. Without Jenkins all works fine. But when I build it with Jenkins, I got nothing... no errors, just nothing. What's wrong? Jenkins can't use PowerShell workflow?
Simple example:
workflow config {
Param([string[]]$servers, $MaxEnvSize, $MaxMemPerShell)
$servers = $servers.Trim()
foreach -parallel -throttlelimit 50 ($server in $servers) {
if (Test-Connection -ComputerName $server -Quiet -Count 1) {
inlinescript {
try {
Invoke-Command -ComputerName $using:server -ea Stop -ScriptBlock {
Param($MaxEnvSize, $MaxMemPerShell)
Set-Item WSMan:\localhost\MaxEnvelopeSizekb -EA Stop -Value $MaxEnvSize
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB -EA Stop $MaxMemPerShell
Set-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB -EA Stop $MaxMemPerShell
#Restart-Service winrm
} -ArgumentList $using:MaxEnvSize , $using:MaxMemPerShell
} catch {
"$using:server : $Error[0].Exception"
}
}
} else {
Write-Output "$server no ping"
}
}
}
config -Servers $env:servers -MaxEnvSize 16454 -MaxMemPerShell 5192
By default jenkins will use 32-bit powershell. Powershell workflow is supported only in 64-bit powershell. trigger powershell script using C:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe which will redirect to 64-bit powershell.