Windows PowerShell Scripting and Administration

Test your knowledge of Windows PowerShell including CmdLets, loops, arrays, hash tables, WMI objects, Active Directory, registry operations, and error handling.

20 Questions Published

Questions

Question 1 True/False

Get-Member CmdLet is used to get the information on the object structure of a CmdLet member. The above statement is True/False?

  1. True
  2. False
Question 2 Multiple Choice (Single Answer)

Which CmdLet will get the full name, Creation Time and Last write time of all the files inside C:\Windows folder recursively.

  1. Get-ChildItem C:\Windows -Recurse | Format-List -Property FullName,CreationTime,LastWriteTime
  2. Get-ChildItem C:\Windows -Recursively | Format-List -Property FullName,CreationTime,LastWriteTime
  3. Get-Children C:\Windows -Recurse | Format-List -Property FullName,CreationTime,LastWriteTime
  4. Get- Children C:\Windows - Recursively | Format-List -Property FullName,CreationTime,LastWriteTime
Question 3 Multiple Choice (Single Answer)

Which one among the following is not valid while declaring the scope of a variable in PowerShell?

  1. $global:a = 1
  2. $public:a = 1
  3. $private:a = 1
  4. $local:a = 1
Question 4 Multiple Choice (Single Answer)

Which object needs to be created in PowerShell to search users in Active Directory (ADSI)?

  1. DirectoryServices.SearchResult
  2. DirectoryServices.DirectoryEntry
  3. DirectoryServices.DirectorySearcher
  4. DirectoryServices.SearchResultCollection
Question 5 Multiple Choice (Single Answer)

To suppress runtime exceptions in PowerShell and continue the execution of CmdLets which option is used in –ErrorAction common parameter?

  1. Continue
  2. Suppress
  3. SilentlyContinue
  4. none of the above
Question 6 Multiple Choice (Single Answer)

What will be the length (Count of items) of Hash Table “$EmpNumbers” after executing the below CmdLets? $EmpNumbers = @{”John Doe” = 112233; “Dave Davis” = 223344; “Justine Smith” = 334455} $EmpNumbers["Rose Jones"] = 445566 $EmpNumbers.Remove(”Dave Davis”)

  1. 0
  2. 1
  3. 2
  4. 3
Question 7 Multiple Choice (Single Answer)

If $a = “This is a string” then which of the below CmdLet will give the output as “a str”?

  1. $a.Substring(($a.length/4), ($a.length/2))
  2. $a.Substring(($a.length/2), ($a.length/3))
  3. $a.Substring(($a.length/3), ($a.length/2))
  4. $a.Substring(($a.length/2), ($a.length/4))
Question 8 Multiple Choice (Single Answer)

What is the correct order in which PowerShell tries to resolve the commands?

  1. aliases, functions, CmdLets, scripts, executables, and normal files
  2. aliases, CmdLets, functions ,scripts, executables, and normal files
  3. aliases, CmdLets, functions , executables, scripts, and normal files
  4. aliases, scripts, CmdLets, functions , executables, and normal files
Question 9 Multiple Choice (Single Answer)

In Windows PowerShell scripting which of the below is used to catch exceptions occurred during CmdLet execution?

  1. Catch
  2. Get
  3. Throw
  4. Trap
Question 10 Multiple Choice (Single Answer)

Which among the below CmdLet is used to get the system related information such as OS version, IP address, Host details etc.?

  1. Invoke-WmiMethod
  2. Get-WmiObject
  3. Get-WmiClass
  4. none of the above
Question 11 Multiple Choice (Single Answer)

X = @(1, 2, 3, 4, 5) If the below script will be executed what will be the value of $Z[6]? $x = @(1, 2, 3, 4, 5) $y = @(6, 7, 8, 9, 10) $z = $x + $y

  1. 5
  2. 6
  3. 7
  4. 8
Question 12 Multiple Choice (Single Answer)

Which CmdLet among the following options is used to read the items inside the windows registry?

  1. Get-ItemProperty
  2. Get-Member
  3. Get-ChildItem
  4. Get-Children
Question 13 Multiple Choice (Single Answer)

Which of the Win32 class is used in PowerShell to get the list of shared folders in a Local/Remote System?

  1. Win32_Directory
  2. Win32_Share
  3. Win32_Volume
  4. Win32_SystemPartitions
Question 14 Multiple Choice (Single Answer)

Which Win32 class is used in PowerShell to get the TimeZone information of a Local/Remote Server?

  1. Win32_Desktop
  2. Win32_Enviornment
  3. Win32_TimeZoneSetting
  4. Win32_TimeZone
Question 15 Multiple Choice (Single Answer)

Which .Net Class is used in PowerShell to get the Event log information of a Local/Remote Server?

  1. System.Diagnostics.EventInstance
  2. System.Diagnostics.EventLogEntry
  3. System.Diagnostics.EventLog
  4. System.Diagnostics.EventLogEntryCollection
Question 16 Multiple Choice (Single Answer)

What will be the output of the below CmdLet? $i = 1 do {Write-Host $i; $i++} while ($i-le 5) {Write-Host $i; $i++}

  1. 1 2 3 4 5
  2. 1
  3. 5
  4. none of the above
Question 17 Multiple Choice (Single Answer)

Which PS Snap-In is required to be imported in PowerShell to achieve IIS 7.0 related administrative tasks.

  1. Microsoft.PowerShell.Core
  2. Microsoft.PowerShell. Management
  3. Microsoft.PowerShell.Utility
  4. WebAdministration
Question 18 Multiple Choice (Single Answer)

Which of the below commands finds out the last logged on users in a Local/Remote systems?

  1. Gwmi Win32_Computersystem -Comp “.” | Select Name, UserName
  2. Get-WMIObject Win32_Computersystem -Comp “.” | Select Name, UserName
  3. Get-WMIObject Win32_Computersystem -Comp “localhost” | Select Name, UserName
  4. all of the above
Question 19 Multiple Choice (Single Answer)

Using which option in PowerShell, you can come out of the loop statements implemented using ForEach, For, While, Do While or Switch Statements.

  1. Exit
  2. Break
  3. Return
  4. Jump
Question 20 Multiple Choice (Single Answer)

Which of the below CmdLet will create an object of the MS Excel?

  1. New-Object -Com Excel.Application
  2. New-Item -Com Excel.Application
  3. Invoke-Item -Com Excel.Application
  4. All of the above