Skip to content

Instantly share code, notes, and snippets.

@bryanvine
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanvine/ad340458dfcaf31756fe to your computer and use it in GitHub Desktop.
Save bryanvine/ad340458dfcaf31756fe to your computer and use it in GitHub Desktop.
Exampe - Invoke-Multithread
#http://www.bryanvine.com/2015/06/powershell-script-invoke-multithread.html
#ScriptBlock: function declaration with function name on the last line without the -ComputerName parameter
$SB = {
Function Check-WindowsServer{
param(
[string[]]$ComputerName
)
foreach ($server in $ComputerName){
if(Test-Path "\\$server\c$\windows"){
Write-Output "Is a Windows Server"
}
else{
Write-Output "Is NOT a Windows Server"
}
}
}
Check-WindowsServer}
Invoke-Multithread -ComputerName (Get-Content .\myserverlist.txt) -ScriptBlock $SB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment