Last active
August 29, 2015 14:23
-
-
Save bryanvine/ad340458dfcaf31756fe to your computer and use it in GitHub Desktop.
Exampe - Invoke-Multithread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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