PowerShell Scripting and Administration
Test your knowledge of PowerShell cmdlets, scripting, WMI, process management, and Windows system administration tasks
Questions
In Windows PowerShell, operators are evaluated in the following precedence: () {}, @ $, !, [ ], ., &, ++ --, Unary + -, * / %, Binary + -, Comparison Operators, -and –or, |, > >>, =
- True
- False
Which among the below options are correctly declaring a Two Dimensional Array in PowerShell?
- $array2 = New-Object 'object[,]' 10,20
- $array1[2][0]
- $array2[9,16]
- $array2[4,8] = 'Hello,Test'
Select all the Valid Snap-Ins available in PowerShell by default and can be loaded on demand.
- Microsoft.PowerShell.Core
- Microsoft.PowerShell. Management
- Microsoft.PowerShell.Utility
- Microsoft.PowerShell.Script
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?
- 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?
- True
- False
Which of the below statement(s) is/are correct?
- Variables in the global scope are visible in all scopes
- Variables in the script scope are visible to all scopes within that script file.
- Variables in the local scope are visible only in the current scope and not to its children.
- Private scope variables are visible only to that current scope.
Which of the below CmdLet will clear all the entries inside “MyLog” in the Eventlog section of a Local/Remote Server?
- $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog Application, $computername $RemoteAppLog.Clear()
- $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Remove()
- $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Delete()
- $RemoteAppLog = New-Object -TypeName System.Diagnostics.EventLog MyLog,$computername $RemoteAppLog.Clear()
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
- "This is" , "a sample" , "PowerShell" , "Script"
- This is ,a sample ,PowerShell ,Script
- This is:a sample:PowerShell:Script
- This is a sample PowerShell Script
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)
- red orange Purple
- Green blue Purple
- red yellow Green
- red yellow Orange
Which of the below CmdLet will return all the Process that was running from a given date?
- \$GivenDate = <<Your Given Date>> Get-Process | Where {\$_.starttime -le [datetime]::\$GivenDate}
- \$GivenDate = 4/07/2010 Get-Process | Where {\$_.starttime -ge [datetime]::\$GivenDate}
- \$GivenDate = 4/07/2010 Get-Process | Where {\$_.starttime -like [datetime]::\$GivenDate}
- \$GivenDate = 4/07/2010 Get-Process | Where {\$_.starttime -neq [datetime]::\$GivenDate}
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}
- List the names of all the local Groups available in a Remote computer
- List the names of all the local Groups available in a Remote computer and find members of each group
- None of the above
- All of the above
Which of the below CmdLet will provide all the applications installed in a Local/Remote system?
- \$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Installed \$Items = \$keys |foreach-object {Get-ItemProperty \$_.PsPath}
- \$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall \$Items = \$keys |foreach-object {Get-ItemProperty \$_.PsPath}
- \$Keys = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall \$Items = \$keys |foreach-object {Get-ChildItem \$_.PsPath}
- None of the above
Which of the below script gives the name of memory slots installed in a system and the size of each memory slot(RAM)?
- \$strComputer = "Computer name" \$colRAM = Get-WmiObject -Class "win32_PhysicalMemory" -namespace "root\CIMV2"-computerName \$strComputer Foreach (\$objRAM In \$colRAM) { "Memory Installed: " + \$objRAM.DeviceLocator &quo
- \$strComputer = "Computer name" \$colRAM = Get-WmiObject -Class "win32_PhysicalMemoryArray" -namespace "root\CIMV2"-computerName \$strComputer Foreach (\$objRAM In \$colRAM) { "Memory Installed: " + \$objRAM.DeviceLocator
- \$strComputer = "Computer name" \$colRAM = Get-WmiObject -Class "win32_PhysicalMemorySize" -namespace "root\CIMV2"-computerName \$strComputer Foreach (\$objRAM In \$colRAM) { "Memory Installed: " + \$objRAM.DeviceLocator
- None of the above
Which of the bellow command will list out all the Win32 classes available in PowerShell WMI in a tabular format and sorted by Name?
- Get-WMIObject -List| Where{$_.name -match "^Win32_"} | Sort Name | Format-Table Name
- Get-WMIObject -Table| Where{$_.name -match "^Win32_"} | Sort Class | Format-Table Name
- Get-WMIObject -List| Where{$_.name -notlike "^Win32_"} | Sort Name | Format-Table Name
- Get-WMIObject -List| Where{$_.name -like "^Win32_*"} | Sort Name | Format-Table Name
Which of the below CmdLet kills a Specific Process running in local system?
- Get-Process | Where { $_.Name -Eq “ProcessName” } | Terminate
- Get-Process | Where { $_.Name -neq “ProcessName” } | Kill
- Get-Process | Where { $_.Name -like “ProcessName” } | Terminate
- Get-Process | Where { $_.Name -Eq “ProcessName” } | Kill
Which of the below CmdLet Displays the TimeZone settings of a remote server?
- get-wmiobject -Class "win32_Desktop" -namespace "root\CIMV2"-computername $computername | Format-List *
- get-wmiobject -Class "win32_Enviornmanet" -namespace "root\CIMV2"-computername $computername | Format-List *
- get-wmiobject -Class "win32_TimeZone" -namespace "root\CIMV2"-computername $computername | Format-List *
- get-wmiobject -Class "win32_TimeZoneSetting" -namespace "root\CIMV2"-computername $computername | Format-List *
What will be the output of the below script? While (1) { $a = "something" if ($a –eq 1) {continue} break; Write-Host $a }
- Something
- 1
- Error
- No output
Out of the below options which is not a valid parameter type in PowerShell?
- Mandatory
- Named
- Generic
- Positional
Which of the below CmdLet is used to find the time required for another CmdLet to execute?
- Measure-CommandLet
- Measure-Command
- Measure-Time
- None of the above
Which of the below CmdLet deletes the output of a CmdLet after execution instead of sending it back to the console?
- Out-Null
- Out-Default
- Out-Host
- Out-Buffer