Skip to content

Instantly share code, notes, and snippets.

@krisdb2009
Created May 12, 2019 13:10
Show Gist options
  • Save krisdb2009/1b31d59725105b9705c172a93e9a9e99 to your computer and use it in GitHub Desktop.
Save krisdb2009/1b31d59725105b9705c172a93e9a9e99 to your computer and use it in GitHub Desktop.
$computer = Read-Host -Prompt "Enter PC Name"
Write-Host "Pinging $computer..."
if (Test-Connection -Computername $computer -BufferSize 16 -Count 1 -Quiet) {
Write-Host "Starting WinRM on $computer..."
Start-Process -WindowStyle Hidden -FilePath "wmic.exe" -ArgumentList "/node:`"$computer`" process call create `"cmd.exe /c winrm quickconfig -quiet -force`"" -Wait
Write-Host "Connecting to $computer..."
Enter-PSSession -ComputerName $computer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment