You want to run a command on multiple remote computers and keep the sessions open for later use. Which approach correctly creates sessions for 'Server01' and 'Server02' and stores them for reuse?
hard📝 Application Q15 of 15
PowerShell - Remote Management
You want to run a command on multiple remote computers and keep the sessions open for later use. Which approach correctly creates sessions for 'Server01' and 'Server02' and stores them for reuse?
Step 1: Recall how to create persistent sessions for multiple computers
New-PSSession can take multiple ComputerName values or create separately and collect into an array with +=. Invoke-Command must use -Session $sessions (array) to run on persistent sessions.
Step 2: Evaluate each option
A creates sessions but uses -ComputerName on Invoke-Command, creating temporary connections instead of using persistent ones. B builds the array explicitly and uses -Session. C uses temporary only. D removes sessions.