- What is PowerShell?
a) A programming language
b) A command-line shell scripting tool
c) A database management software
d) A web development platform
Answer: b) A command-line shell scripting tool
- Which of the following is not a PowerShell verb?
a) Get
b) Set
c) Delete
d) Add
Answer: c) Delete
- Which of the following cmdlets is used to retrieve objects from a remote system?
a) Export-Csv
b) Get-WmiObject
c) Set-Variable
d) Out-File
Answer: b) Get-WmiObject
- What is the default execution policy for PowerShell scripts?
a) Restricted
b) Unrestricted
c) Undefined
d) RemoteSigned
Answer: a) Restricted
- Which of the following operators is used to compare two values in PowerShell?
a) ==
b) =
c) =>
d) <=
Answer: a) ==
- Which of the following parameters can be used with Get-ChildItem cmdlet to only show hidden files?
a) -IncludeHidden
b) -ExcludeHidden
c) -Force
d) -Hidden
Answer: d) -Hidden
- Which of the following cmdlets is used to stop a running process?
a) Stop-Process
b) Kill-Process
c) End-Process
d) Terminate-Process
Answer: a) Stop-Process
- What is the purpose of the Set-ExecutionPolicy cmdlet?
a) To change the PowerShell execution policy
b) To set the data type of a variable
c) To create a new function
d) To modify the content of a file
Answer: a) To change the PowerShell execution policy
- Which of the following cmdlets is used to create a new directory in PowerShell?
a) New-Directory
b) Make-Directory
c) Create-Directory
d) New-Item
Answer: d) New-Item
- How can you run a PowerShell script on a remote computer?
a) Use Invoke-Command cmdlet with -FilePath parameter
b) Use Start-Process cmdlet with -FilePath parameter
c) Use Enter-PSSession cmdlet
d) Use Export-ScheduledJob cmdlet
Answer: a) Use Invoke-Command cmdlet with -FilePath parameter
- Which of the following cmdlets is used to measure the execution time of a script?
a) Measure-Object
b) Get-TimeZone
c) Get-Date
d) Get-ChildItem
Answer: a) Measure-Object
- Which of the following cmdlets is used to get information about installed Windows updates?
a) Get-Process
b) Get-Service
c) Get-Hotfix
d) Get-AppxPackage
Answer: c) Get-Hotfix
- What is the purpose of the Select-Object cmdlet in PowerShell?
a) To filter the output of a command
b) To sort the output of a command
c) To select specific properties from the output of a command
d) To select specific methods from the output of a command
Answer: c) To select specific properties from the output of a command
- Which of the following cmdlets is used to list all the running processes in PowerShell?
a) Get-Process
b) Get-Service
c) Get-ChildItem
d) Get-NetIPConfiguration
Answer: a) Get-Process
- Which of the following operators is used to combine two or more conditions in PowerShell?
a) –
b) &&
c) ||
d) +
Answer: b) &&
- Which of the following cmdlets is used to remove an item from the file system?
a) Remove-Item
b) Delete-Item
c) Destroy-Item
d) Kill-Item
Answer: a) Remove-Item
- How can you loop through the items in an array in PowerShell?
a) Use the for loop
b) Use the while loop
c) Use the foreach loop
d) Use the do-while loop
Answer: c) Use the foreach loop
- Which of the following cmdlets is used to display the current PowerShell version?
a) Get-PowerShellVersion
b) Get-Version
c) Get-Module
d) Get-Help
Answer: c) Get-Module
- Which of the following cmdlets is used to list all the services in PowerShell?
a) Get-Process
b) Get-Service
c) Get-ChildItem
d) Get-NetIPConfiguration
Answer: b) Get-Service
- Which of the following operators is used to redirect output to a file in PowerShell?
a) >
b) |
c) >
d) <
Answer: a) >
- Which of the following cmdlets is used to get help on a specific cmdlet or keyword in PowerShell?
a) Get-Help
b) Get-Command
c) Get-Module
d) Get-Service
Answer: a) Get-Help
- Which of the following cmdlets is used to retrieve information on running processes and related system information?
a) Get-Process
b) Get-Service
c) Get-WinEvent
d) Get-WmiObject
Answer: d) Get-WmiObject
- What is the purpose of the ForEach-Object cmdlet in PowerShell?
a) To loop through a collection of objects and perform an operation on each object
b) To display the current date and time
c) To add items to an array
d) To sort a collection of objects
Answer: a) To loop through a collection of objects and perform an operation on each object
- Which of the following cmdlets is used to get a list of available cmdlets in PowerShell?
a) Get-Command
b) Get-Help
c) Get-Module
d) Get-Parameter
Answer: a) Get-Command
- What is the difference between Write-Output and Write-Host cmdlets in PowerShell?
a) Write-Output can be piped while Write-Host cannot be piped.
b) Write-Host writes output to the console while Write-Output writes output to the pipeline.
c) Write-Host writes output to the pipeline while Write-Output writes output to the console.
d) Write-Output and Write-Host cmdlets are the same.
Answer: b) Write-Host writes output to the console while Write-Output writes output to the pipeline.
- Which of the following cmdlets is used to list all the environment variables in PowerShell?
a) Get-Environment
b) Get-Variable
c) Get-Path
d) Get-ChildItem
Answer: b) Get-Variable
- Which of the following cmdlets is used to display the contents of a file in PowerShell?
a) Get-Content
b) Set-Content
c) Out-File
d) Copy-Item
Answer: a) Get-Content
- What is the purpose of the Where-Object cmdlet in PowerShell?
a) To filter data based on a specific criterion
b) To sort data in ascending or descending order
c) To group data based on a specific property
d) To select specific properties from a collection of objects
Answer: a) To filter data based on a specific criterion
- Which of the following operators is used to perform a case-insensitive comparison in PowerShell?
a) -eq
b) -ne
c) -ceq
d) -cne
Answer: c) -ceq
- Which of the following cmdlets is used to extract specific elements from an array in PowerShell?
a) Select-String
b) Select-Object
c) Select-Xml
d) Select-Array
Answer: b) Select-Object
- Which of the following cmdlets is used to convert a number to a string in PowerShell?
a) ConvertTo-String
b) ConvertFrom-String
c) ConvertTo-Number
d) ConvertFrom-Number
Answer: a) ConvertTo-String
- Which of the following cmdlets is used to get information about disk drives in PowerShell?
a) Get-WmiObject
b) Get-Process
c) Get-Service
d) Get-Disk
Answer: d) Get-Disk
- What is the purpose of the Split method in PowerShell?
a) To divide a string into multiple substrings based on a specific delimiter
b) To concatenate two or more strings
c) To remove white spaces from a string
d) To convert a string to uppercase or lowercase
Answer: a) To divide a string into multiple substrings based on a specific delimiter
- Which of the following cmdlets is used to list all the installed modules in PowerShell?
a) Get-Command
b) Get-Process
c) Get-Module
d) Get-Service
Answer: c) Get-Module
- What is the purpose of the Sort-Object cmdlet in PowerShell?
a) To sort data in ascending or descending order based on a specific property
b) To select specific properties from a collection of objects
c) To group data based on a specific property
d) To filter data based on a specific criterion
Answer: a) To sort data in ascending or descending order based on a specific property
- Which of the following operators is used to perform a case-sensitive comparison in PowerShell?
a) -eq
b) -ne
c) -ceq
d) -cne
Answer: a) -eq
- Which of the following cmdlets is used to get the contents of a remote file in PowerShell?
a) Get-ChildItem
b) Invoke-Command
c) Copy-Item
d) Move-Item
Answer: b) Invoke-Command
- Which of the following cmdlets is used to display the contents of a directory in PowerShell?
a) Get-Content
b) Get-WmiObject
c) Get-ChildItem
d) Get-Service
Answer: c) Get-ChildItem
- What is the purpose of the Join method in PowerShell?
a) To concatenate two or more strings
b) To divide a string into multiple substrings based on a specific delimiter
c) To remove white spaces from a string
d) To convert a string to uppercase or lowercase
Answer: a) To concatenate two or more strings
- Which of the following cmdlets is used to create a new variable in PowerShell?
a) New-Variable
b) Set-Variable
c) Create-Variable
d) Declare-Variable
Answer: a) New-Variable
- What is the purpose of the Test-Connection cmdlet in PowerShell?
a) To test the network connectivity between two computers
b) To test the syntax of a PowerShell script
c) To test the execution policy of PowerShell
d) To test the PowerShell version
Answer: a) To test the network connectivity between two computers
- Which of the following cmdlets is used to list all the installed programs on a computer in PowerShell?
a) Get-Process
b) Get-Service
c) Get-AppxPackage
d) Get-InstalledProgram
Answer: c) Get-AppxPackage
- What is the purpose of the if statement in PowerShell?
a) To execute a block of code if a condition is true
b) To loop through a block of code while a condition is true
c) To execute a block of code for a specific number of times
d) To define a function in PowerShell
Answer: a) To execute a block of code if a condition is true
- Which of the following cmdlets is used to get information about the file system in PowerShell?
a) Get-ChildItem
b) Get-WmiObject
c) Get-Drive
d) Get-Volume
Answer: c) Get-Drive
- What is the purpose of the break statement in PowerShell?
a) To exit a loop or a switch statement
b) To continue to the next iteration of a loop
c) To create a new line in the output
d) To clear the console screen
Answer: a) To exit a loop or a switch statement
- Which of the following cmdlets is used to create a new registry key in PowerShell?
a) New-RegKey
b) Set-RegKey
c) Create-RegKey
d) New-ItemProperty
Answer: a) New-RegKey
- What is the purpose of the ForEach-Object cmdlet in PowerShell?
a) To loop through a collection of objects and perform an operation on each object
b) To sort data in ascending or descending order based on a specific property
c) To group data based on a specific property
d) To select specific properties from a collection of objects
Answer: a) To loop through a collection of objects and perform an operation on each object
- Which of the following operators is used to perform a wildcard match in PowerShell?
a) *
b) .
c) #
d) %
Answer: a) *
- Which of the following cmdlets is used to get information about the system memory in PowerShell?
a) Get-Process
b) Get-Service
c) Get-WmiObject
d) Get-Memory
Answer: c) Get-WmiObject
- What is the purpose of the switch statement in PowerShell?
a) To execute different blocks of code based on the value of a variable
b) To loop through a block of code while a condition is true
c) To execute a block of code for a specific number of times
d) To define a function in PowerShell
Answer: a) To execute different blocks of code based on the value of a variable.
Latest posts by Ashwani Kumar (see all)
- Top 10 DevOps Trainers in the world - October 7, 2023
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023