1. Which is not a built-in variable out of this
a) $Args
b) $Hostname
c) $Pid
d) $?
2. Which one will override the default alias in Powershell
a) Set-Alias -Name ls -Value hostname -Scope Local -Force
b) Set-Alias -Name ls -Value hostname -Force
c) Set-Alias -Name ls -Value hostname -Option AllScope
d) None of the above, we can't override the default aliases
3. Out of the below which command won't work ( Renaming directory )
a) Rename-Item "C:\`[Test File`]\" "Test"
b) Rename-Item "C:\``[Test File``]\" "Test"
c) Rename-Item -LiteralPath "C:\`[Test File`]\" "Test"
d) Rename-Item -LiteralPath "C:\[Test File]\" "Test"
4. What is the default execution policy in Powershell
a) Bypass
b) Restricted
c) UnRestricted
d) RemoteSigned
5. What will be the output of $Result
$Result = Write-Host "This is my First script" ; $Result
a) Null
b) This is my First script
c) 0
d) None of the above
6. What will be the Output :
$value = "Apple.Orange.Pineapple"
$Orange, $Pineapple = $value.Split(".")
Write-Host "$Orange ; $Pineapple ; $Apple"
a) Apple ; Orange Pineapple ;
b) Orange ; Pineapple ; Apple
c) Apple ; Orange ; Pineapple
d) None of the above
7. What will be the Output :
$Value = "Global-Scope"
function abc {
$Value = "Local-Scope"
Write-Host $global:Value
Write-Host $local:Value
Write-Host $Value
}
abc
Write-Host $local:Value
Write-Host $Value
a) Local-Scope Global-Scope Local-Scope Local-Scope Global-Scope
b) Global-Scope Local-Scope Local-Scope Global-Scope Global-Scope
c) Global-Scope Local-Scope Global-Scope Local-Scope Global-Scope
d) Global-Scope Local-Scope Local-Scope Local-Scope Global-Scope
8. Which below cmdlet is wrong, To Remove a variable ($Var) from Memory
a) Remove-Variable -Name var
b) rv var
c) Remove-Item Variable:\Var
d) rv $var
9. What will be the Output :
$output1 = 4 + "2" ;
$output2 = "4" + 2 ;
Write-Output $output1 , $output2
a) 6 42
b) 42 42
c) 6 6
d) None of the above
10. Which port is used by default for Powershell remoting ( HTTP Listener )
a) 5986
b) 5985
c) 5984
d) 5987
11. Print your name 10 times, Example :
John Doe
John Doe
John Doe
John Doe
John Doe
John Doe
John Doe
John Doe
John Doe
John Doe
Solution : PS C:\> 1..10 | %{write-host "John Doe"}
12. Create a Function to accept a parameter and then reverse it
Example : Reverse-String -Phrase "Powershell"
Output : llehsrewoP
Solution :
Comments
Post a Comment