Run PowerShell custom function in new window

Viewed 3593
Function Check-PC
{
$PC = Read-Host "PC Name"
If($PC -eq "exit"){EXIT}
Else{
Write-Host "Pinging $PC to confirm status..."
PING -n 1 $PC
}

This is a snippet of a function I have written into a PowerShell script. I would like the function to run in a new instance of PowerShell, not in the main window.

Is it possible to run this in a separate process of PowerShell without writing it as a separate script and calling the script? Something like this:

$x= Start-Process powershell | Check-PC

I need to keep everything in one script if possible.

1 Answers
Related