none
start-job RRS feed

  • Question

  • any idea why this is not working with scriptblock?

    $computers = get-content -Path "c:\scripts\servers.txt"

    ForEach($Computer in $Computers){   

    start-job -ScriptBlock "Get-WmiObject -ComputerName $Computer -Class Win32_OperatingSystem"}

    Get-Job | Wait-Job

    Get-Job | Receive-Job | Out-GridView


    but filepath is working

    Start-Job -FilePath "c:\scripts\get-os.ps1" -ArgumentList $Computer

    get-os.ps1

    Param($ComputerName = "LocalHost")
    Get-WmiObject -ComputerName $ComputerName -Class Win32_OperatingSystem

    • Edited by JonDoe321 Sunday, July 7, 2019 4:08 PM
    Sunday, July 7, 2019 4:06 PM

All replies