PowerShell Scripting and Administration

Test your knowledge of PowerShell cmdlets, scripting, WMI, process management, and Windows system administration tasks

20 Questions Published

Questions

Question 1 True/False

In Windows PowerShell, operators are evaluated in the following precedence: () {}, @ $, !, [ ], ., &, ++ --, Unary + -, * / %, Binary + -, Comparison Operators, -and –or, |, > >>, =

  1. True
  2. False
Question 2 Multiple Choice (Multiple Answers)

Which among the below options are correctly declaring a Two Dimensional Array in PowerShell?

  1. $array2 = New-Object 'object[,]' 10,20
  2. $array1[2][0]
  3. $array2[9,16]
  4. $array2[4,8] = 'Hello,Test'
Question 3 Multiple Choice (Multiple Answers)

Select all the Valid Snap-Ins available in PowerShell by default and can be loaded on demand.

  1. Microsoft.PowerShell.Core
  2. Microsoft.PowerShell. Management
  3. Microsoft.PowerShell.Utility
  4. Microsoft.PowerShell.Script
Question 4 True/False

If a Snap-in is not registered, Still PowerShell can load the Snap-in and access it’s methods. The Above statement is true or false?

  1. True
  2. False
Question 5 True/False

If a Snap-in is not registered, Still PowerShell can load the Snap-in and access it’s methods. The Above statement is true or false?

  1. True
  2. False
Question 6 Multiple Choice (Multiple Answers)

Which of the below statement(s) is/are correct?

  1. Variables in the global scope are visible in all scopes
  2. Variables in the script scope are visible to all scopes within that script file.
  3. Variables in the local scope are visible only in the current scope and not to its children.
  4. Private scope variables are visible only to that current scope.
Question 7 Multiple Choice (Single Answer)

Which of the below CmdLet will clear all the entries inside “MyLog” in the Eventlog section of a Local/Remote Server?

  1. $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog Application, $computername $RemoteAppLog.Clear()
  2. $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Remove()
  3. $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Delete()
  4. $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Clear()
Question 8 Multiple Choice (Single Answer)

What will be the output of the below Script? $Array = @() $TempValue = "This is" , "a sample" , "PowerShell" , "Script" $Value =[string]::join(':', $TempValue) $Array = $Array + $Value $Array

  1. "This is" , "a sample" , "PowerShell" , "Script"
  2. This is ,a sample ,PowerShell ,Script
  3. This is:a sample:PowerShell:Script
  4. This is a sample PowerShell Script
Question 9 Multiple Choice (Single Answer)

The ArrayList $a will have which of the below items after executing the below script? $a = New-Object System.Collections.ArrayList $a.Add("red") $a.Add("yellow") $a.Add("orange") $a.Add("green") $a.Add("blue") $a.Add("purple") $a.RemoveRange(3,3)

  1. red orange Purple
  2. Green blue Purple
  3. red yellow Green
  4. red yellow Orange
Question 10 Multiple Choice (Single Answer)

Which of the below CmdLet will return all the Process that was running from a given date?

  1. \$GivenDate = <<Your Given Date>> Get-Process | Where {\$_.starttime -le [datetime]::\$GivenDate}
  2. \$GivenDate = 4/07/2010 Get-Process | Where {\$_.starttime -ge [datetime]::\$GivenDate}
  3. \$GivenDate = 4/07/2010 Get-Process | Where {\$_.starttime -like [datetime]::\$GivenDate}
  4. \$GivenDate = 4/07/2010 Get-Process | Where {\$_.starttime -neq [datetime]::\$GivenDate}
Question 11 Multiple Choice (Single Answer)

What action the below script will perform? $strComputer = “Remote Computer Name” $computer = [ADSI](“WinNT://” + $strComputer + “,computer”) $group = $computer.psbase.children |where{$_.psbase.schemaclassname -eq “group”} foreach ($member in $group.psbase.syncroot) {$member.name}

  1. List the names of all the local Groups available in a Remote computer
  2. List the names of all the local Groups available in a Remote computer and find members of each group
  3. None of the above
  4. All of the above
Question 12 Multiple Choice (Single Answer)

Which of the below CmdLet will provide all the applications installed in a Local/Remote system?

  1. \$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Installed \$Items = \$keys |foreach-object {Get-ItemProperty \$_.PsPath}
  2. \$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall \$Items = \$keys |foreach-object {Get-ItemProperty \$_.PsPath}
  3. \$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall \$Items = \$keys |foreach-object {Get-ChildItem \$_.PsPath}
  4. None of the above
Question 13 Multiple Choice (Single Answer)

Which of the below script gives the name of memory slots installed in a system and the size of each memory slot(RAM)?

  1. \$strComputer = "Computer name" \$colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2"-computerName \$strComputer Foreach (\$objRAM In \$colRAM) { "Memory Installed: " + \$objRAM.DeviceLocator &quo
  2. \$strComputer = "Computer name" \$colRAM = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2"-computerName \$strComputer Foreach (\$objRAM In \$colRAM) { "Memory Installed: " + \$objRAM.DeviceLocator
  3. \$strComputer = "Computer name" \$colRAM = Get-WmiObject -Class "win32_PhysicalMemorySize" -namespace "root\CIMV2"-computerName \$strComputer Foreach (\$objRAM In \$colRAM) { "Memory Installed: " + \$objRAM.DeviceLocator
  4. None of the above
Question 14 Multiple Choice (Single Answer)

Which of the bellow command will list out all the Win32 classes available in PowerShell WMI in a tabular format and sorted by Name?

  1. Get-WMIObject -List| Where{$_.name -match "^Win32_"} | Sort Name | Format-Table Name
  2. Get-WMIObject -Table| Where{$_.name -match "^Win32_"} | Sort Class | Format-Table Name
  3. Get-WMIObject -List| Where{$_.name -notlike "^Win32_"} | Sort Name | Format-Table Name
  4. Get-WMIObject -List| Where{$_.name -like "^Win32_*"} | Sort Name | Format-Table Name
Question 15 Multiple Choice (Single Answer)

Which of the below CmdLet kills a Specific Process running in local system?

  1. Get-Process | Where { $_.Name -Eq “ProcessName” } | Terminate
  2. Get-Process | Where { $_.Name -neq “ProcessName” } | Kill
  3. Get-Process | Where { $_.Name -like “ProcessName” } | Terminate
  4. Get-Process | Where { $_.Name -Eq “ProcessName” } | Kill
Question 16 Multiple Choice (Single Answer)

Which of the below CmdLet Displays the TimeZone settings of a remote server?

  1. get-wmiobject -Class "win32_Desktop" -namespace "root\CIMV2"-computername $computername | Format-List *
  2. get-wmiobject -Class "win32_Enviornmanet" -namespace "root\CIMV2"-computername $computername | Format-List *
  3. get-wmiobject -Class "win32_TimeZone" -namespace "root\CIMV2"-computername $computername | Format-List *
  4. get-wmiobject -Class "win32_TimeZoneSetting" -namespace "root\CIMV2"-computername $computername | Format-List *
Question 17 Multiple Choice (Single Answer)

What will be the output of the below script? While (1) { $a = "something" if ($a –eq 1) {continue} break; Write-Host $a }

  1. Something
  2. 1
  3. Error
  4. No output
Question 18 Multiple Choice (Single Answer)

Out of the below options which is not a valid parameter type in PowerShell?

  1. Mandatory
  2. Named
  3. Generic
  4. Positional
Question 19 Multiple Choice (Single Answer)

Which of the below CmdLet is used to find the time required for another CmdLet to execute?

  1. Measure-CommandLet
  2. Measure-Command
  3. Measure-Time
  4. None of the above
Question 20 Multiple Choice (Single Answer)

Which of the below CmdLet deletes the output of a CmdLet after execution instead of sending it back to the console?

  1. Out-Null
  2. Out-Default
  3. Out-Host
  4. Out-Buffer