Final answer:
The Powershell for loop to print specified even numbers is achieved using a modulo operation within the loop. For the date format, the Get-Date cmdlet along with the -Format parameter is used to output the current time with only hours and minutes.
Step-by-step explanation:
For the Powershell for loop requirement, you would need to use the modulo operator to achieve the result which prints only even numbers excluding zero, as follows:
for ($i = 0; $i -le 5; $i++) {
if ($i % 2 -eq 0 -and $i -ne 0) {
Write-Output $i
}
}
This loop starts at 0, increments by 1 up to 5, and uses an if statement to check if the number is even and not zero before printing it.
Regarding the Powershell date format statement to print the time in a specific format, use the Get-Date cmdlet combined with the -Format parameter:
Get-Date -Format "HH:mm"
This command will display the current time in a 24-hour format without seconds, just as required.