POST Module Jobs Dump content to Runspace

Hello All.

just wanted to know if anyone here can guide about POST Module execution …

I created a master script that calls another slave script to perform steps on couple of servers. this calling is performed by using start-rsjob cmdlet of POSH module, and below is the complete command…


#importing PoshRSJob Module

Import-Module -Name PoshRSJob

#performing action for each server - parallel

foreach ($server in $servers){

Start-RSJob -FilePath “D:\slave.ps1” -ArgumentList $server, $masterdirpath -Name “Job-$server -Throttle 50

}


the Slave.ps1 script performs some steps on servers, like getting OS info, diskspace, etc etc…

everything runs perfectly fine, all output, execution, etc are perfectly running as expected.

the thing is while it performs parallel execution using start-rs job -> it dump entire content of slave.ps1 into runspace in command column instead of giving row -wise results of all jobs that are started…see below…


Name : XXXXXXXX
ID : 7
State : Running
InputObject :
InstanceID : c9c54301-5c87-4dfb-bd25-c0a5167ddcff
Handle : System.Management.Automation.PowerShellAsyncResult
Runspace :
InnerJob : System.Management.Automation.PowerShell
Finished : System.Threading.ManualResetEvent
Command : [CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
$computer,
$dirpath
)
$csvfile = “$computer.csv”
New-Item -Path $dirpath -Name $csvfile -ItemType File | Out-Null
$servercsvfilepath = “$dirpath” + “” + “$csvfile”
Set-Content -Path $servercsvfilepath -Value “Server, PING, Is_Accessible, IS_RDP, WinRM, WMI, OS
Version, SVC_LSM, SVC_Netlogon, SVC_WTime, SVC_Server, SVC_SCCM, SVC_MS Mon Agent, SVC_Netbackup, C:
(Free %), Last Reboot, Patch Day” -Encoding Ascii
$online = $access = $rdp = $null
$sping = $saccess = $isrdp = $socket = $winrm = $srvwmi = $svclms = $SVCnetlogon = $SVCwtime =
$svclanman = $SVCsms = $SVCmma = $patchday = $null
$os = $caption = $uptime = $SVCbackup = $null
$cdrivespace = $percent = $null
$online = Test-Connection -ComputerName $computer -Count 2 -Quiet
if (-not $online){
$sping = “No”
$saccess = $isrdp = $winrm = $srvwmi = $caption = $svclms = $SVCnetlogon = $SVCwtime = $svclanman
= $SVCsms = $SVCmma = $SVCbackup = $cdrivespace = $percent = $uptime = $patchday = $null
}
else{
$sping = “Yes”
$nameofservice = $null
$valueofservice = $null
if (Test-Path -Path ("\$computer\c$") -ErrorAction SilentlyContinue){
$saccess = “Yes”
$socket = New-Object Net.Sockets.TcpClient($myserver, 3389)
if ($socket.Connected -eq ‘TRUE’){
$isrdp = “Yes”
}
else{
$isrdp = “No”
}
Error :
Verbose :
Debug :
Warning :
Progress :
HasMoreData : False
HasErrors : False
Output :
RunspacePoolID : 428d4e78-de4d-4fdf-aba2-2dd601f57ef3
Completed : False
Batch : 428d4e78-de4d-4fdf-aba2-2dd601f57ef3


I believe it should display all jobs in rows (which you would get when you do get-rsjob) but its not…

any idea/help please…

Thank you.