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.
Questions
Get-Member CmdLet is used to get the information on the object structure of a CmdLet member. The above statement is True/False?
- True
- False
Which CmdLet will get the full name, Creation Time and Last write time of all the files inside C:\Windows folder recursively.
- Get-ChildItem C:\Windows -Recurse | Format-List -Property FullName,CreationTime,LastWriteTime
- Get-ChildItem C:\Windows -Recursively | Format-List -Property FullName,CreationTime,LastWriteTime
- Get-Children C:\Windows -Recurse | Format-List -Property FullName,CreationTime,LastWriteTime
- Get- Children C:\Windows - Recursively | Format-List -Property FullName,CreationTime,LastWriteTime
Which one among the following is not valid while declaring the scope of a variable in PowerShell?
- $global:a = 1
- $public:a = 1
- $private:a = 1
- $local:a = 1
Which object needs to be created in PowerShell to search users in Active Directory (ADSI)?
- DirectoryServices.SearchResult
- DirectoryServices.DirectoryEntry
- DirectoryServices.DirectorySearcher
- DirectoryServices.SearchResultCollection
To suppress runtime exceptions in PowerShell and continue the execution of CmdLets which option is used in –ErrorAction common parameter?
- Continue
- Suppress
- SilentlyContinue
- none of the above
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”)
- 0
- 1
- 2
- 3
If $a = “This is a string” then which of the below CmdLet will give the output as “a str”?
- $a.Substring(($a.length/4), ($a.length/2))
- $a.Substring(($a.length/2), ($a.length/3))
- $a.Substring(($a.length/3), ($a.length/2))
- $a.Substring(($a.length/2), ($a.length/4))
What is the correct order in which PowerShell tries to resolve the commands?
- aliases, functions, CmdLets, scripts, executables, and normal files
- aliases, CmdLets, functions ,scripts, executables, and normal files
- aliases, CmdLets, functions , executables, scripts, and normal files
- aliases, scripts, CmdLets, functions , executables, and normal files
In Windows PowerShell scripting which of the below is used to catch exceptions occurred during CmdLet execution?
- Catch
- Get
- Throw
- Trap
Which among the below CmdLet is used to get the system related information such as OS version, IP address, Host details etc.?
- Invoke-WmiMethod
- Get-WmiObject
- Get-WmiClass
- none of the above
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
- 5
- 6
- 7
- 8
Which CmdLet among the following options is used to read the items inside the windows registry?
- Get-ItemProperty
- Get-Member
- Get-ChildItem
- Get-Children
Which of the Win32 class is used in PowerShell to get the list of shared folders in a Local/Remote System?
- Win32_Directory
- Win32_Share
- Win32_Volume
- Win32_SystemPartitions
Which Win32 class is used in PowerShell to get the TimeZone information of a Local/Remote Server?
- Win32_Desktop
- Win32_Enviornment
- Win32_TimeZoneSetting
- Win32_TimeZone
Which .Net Class is used in PowerShell to get the Event log information of a Local/Remote Server?
- System.Diagnostics.EventInstance
- System.Diagnostics.EventLogEntry
- System.Diagnostics.EventLog
- System.Diagnostics.EventLogEntryCollection
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 2 3 4 5
- 1
- 5
- none of the above
Which PS Snap-In is required to be imported in PowerShell to achieve IIS 7.0 related administrative tasks.
- Microsoft.PowerShell.Core
- Microsoft.PowerShell. Management
- Microsoft.PowerShell.Utility
- WebAdministration
Which of the below commands finds out the last logged on users in a Local/Remote systems?
- Gwmi Win32_Computersystem -Comp “.” | Select Name, UserName
- Get-WMIObject Win32_Computersystem -Comp “.” | Select Name, UserName
- Get-WMIObject Win32_Computersystem -Comp “localhost” | Select Name, UserName
- all of the above
Using which option in PowerShell, you can come out of the loop statements implemented using ForEach, For, While, Do While or Switch Statements.
- Exit
- Break
- Return
- Jump
Which of the below CmdLet will create an object of the MS Excel?
- New-Object -Com Excel.Application
- New-Item -Com Excel.Application
- Invoke-Item -Com Excel.Application
- All of the above