Skip to content

Instantly share code, notes, and snippets.

@kentblake
Created May 5, 2022 05:53
Show Gist options
  • Save kentblake/9b1f040f7f37dc4bc70968826ffc9e59 to your computer and use it in GitHub Desktop.
Save kentblake/9b1f040f7f37dc4bc70968826ffc9e59 to your computer and use it in GitHub Desktop.
powerShellStarterAsync.ps1

param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string[]]$ServerName )

foreach ($s in $ServerName) { $scriptBlock = { if (Test-Connection -ComputerName $args[0] -Quiet -Count 1) { $null = New-Item -Path "\$($args[0])\c$\SomeFolder" -ItemType Directory -Force Set-Content -Path "\$($args[0])\c$\SomeFolder\foo.txt" -Value 'something' } } Start-Job -ScriptBlock $scriptBlock -ArgumentList $s }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment