I am new to this Job things. I am getting the error of : Cannot bind parameter 'ScriptBlock'. Cannot convert the | ".\test7\test7-2.ps1" value of type "System.String" to type "System.Management.Automation.ScriptBlock". Can anyone tell me and figure out what is happening here?
$importCsv = ".\testData.csv"
$dir = "test\"
$main = ".\test7\test7-2.ps1"
$csv = GetCsv $importCsv
foreach ($i in $csv){
Start-Job -ScriptBlock $main -ArgumentList @($dir,$i.ip,$i.openTime,$i.closeTime)
}
the $main is here:
function Main {
param ($directory, $itemIp, $itemOpen, $itemClose)
$ipAddress = $itemIp
$openTime = $itemOpen
$closeTime = $itemClose
$date = Get-Date -Format "yyyy-MM-dd"
$storeFolder = addFolder $directory $ipAddress
$todayDir = addFolder $storeFolder $date
$pingFile = addFile $todayDir
Write-Host "Date : $date"
Write-Host "Store Folder : $storeFolder"
Write-Host "Today Folder : $todayDir"
Write-Host "File path : $pingFile."
Write-Host "ip address : $ipAddress"
Write-Host "Open Time : $openTime"
Write-Host "Close Time : $closeTime"
$time = Get-Date -Format "HH:mm"
Write-Host "Time : $time"
Compare-Time $time $openTime $closeTime $timeNow $ping4 $ping15 $ipAddress $pingFile 4 3 15 1
}
Then I also tried like this $main = .\test\test7-2.ps1 but it return Cannot bind argument to parameter 'ScriptBlock' because it is| null.