Debug School

Akanksha
Akanksha

Posted on

Top 30 powershell Interview Questions with Answers

1. What is PowerShell primarily used for?

A) Video Editing
B) Web Development
C) System Administration
D) Graphic Design
Answer: C) System Administration

2. Which commandlet is used to get the list of all installed modules in PowerShell?

A) Get-InstalledModule
B) Get-ModuleList
C) Get-Module
D) List-Modules
Answer: C) Get-Module

3. What cmdlet is used to display the contents of a text file in PowerShell?

A) Read-File
B) Show-Text
C) Get-Content
D) View-File
Answer: C) Get-Content

4. Which operator is used for pipeline in PowerShell?

A) |
B) &&
C) %
D) ->
Answer: A) |

5. To create a new directory in PowerShell, you would use the cmdlet:

A) New-Directory
B) Make-Dir
C) Create-Folder
D) New-Item
Answer: D) New-Item

6. Which cmdlet is used to list all running processes in PowerShell?

A) Get-ProcessList
B) Show-Processes
C) List-Running
D) Get-Process
Answer: D) Get-Process

7. What does the Set-ExecutionPolicy cmdlet in PowerShell do?

A) Change the execution policy of a script
B) Set the system time
C) Modify the registry
D) Create a new user
Answer: A) Change the execution policy of a script

8. Which cmdlet is used to start a stopped service in PowerShell?

A) Resume-Service
B) Start-Service
C) Begin-Service
D) Launch-Service
Answer: B) Start-Service

9. What cmdlet is used to remove a file in PowerShell?

A) Delete-Item
B) Remove-File
C) Erase-Data
D) Unlink-Item
Answer: A) Delete-Item

10. Which cmdlet is used to filter and format output in PowerShell?

A) Format-Output
B) Select-Object
C) Filter-Data
D) Sort-Results
Answer: B) Select-Object

11. What is the scripting language used by PowerShell?

A) Java
B) C++
C) C#
D) Python
Answer: C) C#

12. Which cmdlet is used to display system information and configuration in PowerShell?

A) Get-Info
B) Show-System
C) System-Info
D) Get-WmiObject
Answer: D) Get-WmiObject

13. To list all environment variables in PowerShell, you would use:

A) List-Environment
B) Get-Env
C) Show-Variables
D) Get-ChildItem Env:
Answer: D) Get-ChildItem Env:

14. What does the Write-Host cmdlet do in PowerShell?

A) Writes to a file
B) Displays text on the console
C) Sends an email
D) Shuts down the system
Answer: B) Displays text on the console

15. Which cmdlet is used to stop a running process in PowerShell?

A) End-Process
B) Stop-Process
C) Terminate-Process
D) Kill-Process
Answer: B) Stop-Process

16. To create a new variable in PowerShell, you would use the cmdlet:

A) New-Variable
B) Create-Var
C) Set-Variable
D) Make-Variable
Answer: A) New-Variable

17. What does the Get-Help cmdlet do in PowerShell?

A) List available hardware
B) Display help information about PowerShell cmdlets
C) Get system logs
D) Create a new user account
Answer: B) Display help information about PowerShell cmdlets

18. Which cmdlet is used to create a new text file in PowerShell?

A) Write-File
B) Create-Text
C) New-File
D) Set-Content
Answer: C) New-File

19. To create a new function in PowerShell, you would use the cmdlet:

A) Define-Function
B) Create-Function
C) New-Function
D) Set-Function
Answer: C) New-Function

20. What is the purpose of the Where-Object cmdlet in PowerShell?

A) To create a new object
B) To filter objects based on a condition
C) To sort objects
D) To rename objects
Answer: B) To filter objects based on a condition

21. Which cmdlet is used to get the current working directory in PowerShell?

A) Get-Path
B) Show-Directory
C) Get-Location
D) Current-Dir
Answer: C) Get-Location

22. What does the Invoke-Command cmdlet do in PowerShell?

A) Run a command on a remote computer
B) Start a local application
C) Reboot the system
D) Display system information
Answer: A) Run a command on a remote computer

23. To list all available aliases in PowerShell, you would use the cmdlet:

A) List-Alias
B) Show-Aliases
C) Get-Alias
D) Alias-List
Answer: C) Get-Alias

24. What is the purpose of the ForEach-Object cmdlet in PowerShell?

A) Start a loop
B) Create an array
C) Execute a script block for each item in a collection
D) Delete files
Answer: C) Execute a script block for each item in a collection

25. Which cmdlet is used to create a new registry key in PowerShell?

A) New-RegistryKey
B) Set-Registry
C) Create-Registry
D) New-ItemProperty
Answer: A) New-RegistryKey

26. To list all installed roles and features in PowerShell, you would use the cmdlet:

A) Get-Roles
B) Show-Features
C) Get-WindowsFeature
D) List-InstalledFeatures
Answer: C) Get-WindowsFeature

27. What is the purpose of the ConvertTo-Json cmdlet in PowerShell?

A) Convert a string to JSON format
B) Convert JSON to a PowerShell object
C) Convert a file to JSON
D) Convert a JSON file to XML
Answer: B) Convert JSON to a PowerShell object

28. Which cmdlet is used to rename a file in PowerShell?

A) Rename-File
B) Set-FileName
C) New-Name
D) Change-File
Answer: A) Rename-File

29. To list all installed Windows updates in PowerShell, you would use the cmdlet:

A) Get-Updates
B) Show-WindowsUpdates
C) Get-Hotfix
D) List-InstalledUpdates
Answer: C) Get-Hotfix

30. What does the Start-Process cmdlet do in PowerShell?

A) Start a new PowerShell session
B) Begin a new script
C) Launch an external program
D) Create a new process
Answer: C) Launch an external program

Top comments (0)