0
0
PowerShellscripting~10 mins

Why remote execution scales management in PowerShell - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run a command remotely on a computer named 'Server01'.

PowerShell
Invoke-Command -ComputerName Server01 -ScriptBlock { Get-Process } -Credential [1]
Drag options to blanks, or click blank then click option'
A$LocalUser
B$UserCredential
C$RemoteSession
D$ProcessList
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable that does not contain credentials causes authentication errors.
Omitting the -Credential parameter leads to permission denied errors.
2fill in blank
medium

Complete the code to create a persistent remote session to 'Server02'.

PowerShell
$session = New-PSSession -ComputerName Server02 -Credential [1]
Drag options to blanks, or click blank then click option'
A$AdminCreds
B$ProcessList
C$LocalSession
D$UserInput
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable without credentials causes session creation to fail.
Confusing session variables with credential variables.
3fill in blank
hard

Fix the error in the code to run a script block on multiple computers stored in $computers.

PowerShell
Invoke-Command -ComputerName [1] -ScriptBlock { Get-Service }
Drag options to blanks, or click blank then click option'
A$computer
Bcomputers
C$computers
D$computerList
Attempts:
3 left
💡 Hint
Common Mistakes
Using a singular variable name when the list is plural.
Omitting the $ sign for variables.
4fill in blank
hard

Fill both blanks to filter services running on remote computers with status 'Running'.

PowerShell
Invoke-Command -ComputerName Server03 -ScriptBlock { Get-Service | Where-Object { $_.Status [1] '[2]' } }
Drag options to blanks, or click blank then click option'
A-eq
BRunning
CStopped
D-ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-ne' (not equal) instead of '-eq'.
Using 'Stopped' instead of 'Running' as the filter value.
5fill in blank
hard

Fill all three blanks to create a hashtable of service names and statuses from remote computers where status is not 'Stopped'.

PowerShell
$results = Invoke-Command -ComputerName Server04 -ScriptBlock { Get-Service | Where-Object { $_.Status [1] '[2]' } | ForEach-Object { @{ [3] = $_.Name; Status = $_.Status } } }
Drag options to blanks, or click blank then click option'
A-ne
BStopped
CName
DServiceName
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-eq' instead of '-ne' for filtering.
Using 'ServiceName' instead of 'Name' as the hashtable key.