Introduction
PowerShell commands, also known as cmdlets, provide direct access to various system functions and features, enabling you to automate tasks, configure settings, and troubleshoot issues effectively. By mastering these commands, you can significantly enhance your ability to manage Windows 11. This guide includes essential PowerShell commands with brief descriptions of their uses.
System Information and Management
-
Get-ComputerInfo: Display detailed information about the computer.
Get-ComputerInfo
-
Get-Process: List all running processes on the system.
Get-Process
-
Stop-Process: Stop a running process by process name or ID.
Stop-Process -Name "notepad" -Force
-
Restart-Computer: Restart the computer.
Restart-Computer
-
Shutdown-Computer: Shutdown the computer.
Stop-Computer
-
Get-Service: List all services on the system.
Get-Service
-
Start-Service: Start a service.
Start-Service -Name "wuauserv"
-
Stop-Service: Stop a service.
Stop-Service -Name "wuauserv"
-
Get-EventLog: Get event log data.
Get-EventLog -LogName "System"
File and Directory Management
-
Get-ChildItem: List the contents of a directory.
Get-ChildItem -Path "C:\Users\YourUsername\Documents"
-
Copy-Item: Copy files or directories.
Copy-Item -Path "C:\Source\file.txt" -Destination "C:\Destination\file.txt"
-
Move-Item: Move files or directories.
Move-Item -Path "C:\Source\file.txt" -Destination "C:\Destination\file.txt"
-
Remove-Item: Delete files or directories.
Remove-Item -Path "C:\Source\file.txt"
-
New-Item: Create a new file or directory.
New-Item -Path "C:\NewFolder" -ItemType Directory
-
Set-Location: Change the current directory.
Set-Location -Path "C:\Users\YourUsername\Documents"
-
Get-Content: Display the contents of a file.
Get-Content -Path "C:\Source\file.txt"
Network Management
-
Get-NetIPConfiguration: Display IP configuration details.
Get-NetIPConfiguration
-
Test-Connection: Test network connectivity (similar to ping).
Test-Connection -ComputerName www.google.com
-
Get-NetAdapter: Display network adapter details.
Get-NetAdapter
-
Disable-NetAdapter: Disable a network adapter.
Disable-NetAdapter -Name "Ethernet" -Confirm:$false
-
Enable-NetAdapter: Enable a network adapter.
Enable-NetAdapter -Name "Ethernet"
User and Group Management
-
Get-LocalUser: List all local user accounts.
Get-LocalUser
-
New-LocalUser: Create a new local user account.
New-LocalUser -Name "NewUser" -Password (ConvertTo-SecureString "Password123" -AsPlainText -Force) -FullName "New User" -Description "Test User"
-
Remove-LocalUser: Delete a local user account.
Remove-LocalUser -Name "NewUser"
-
Get-LocalGroup: List all local groups.
Get-LocalGroup
-
Add-LocalGroupMember: Add a user to a local group.
Add-LocalGroupMember -Group "Administrators" -Member "NewUser"
-
Remove-LocalGroupMember: Remove a user from a local group.
Remove-LocalGroupMember -Group "Administrators" -Member "NewUser"
System Configuration
-
Get-WindowsFeature: List all Windows features and roles.
Get-WindowsFeature
-
Install-WindowsFeature: Install a Windows feature or role.
Install-WindowsFeature -Name "Web-Server"
-
Uninstall-WindowsFeature: Uninstall a Windows feature or role.
Uninstall-WindowsFeature -Name "Web-Server"
-
Get-WindowsUpdateLog: Get Windows Update log details.
Get-WindowsUpdateLog
-
Get-InstalledModule: List all installed PowerShell modules.
Get-InstalledModule
-
Install-Module: Install a PowerShell module from the PowerShell Gallery.
Install-Module -Name "PSReadLine" -Scope CurrentUser
Additional Tips
-
Help Command: Use the
Get-Help
command followed by the cmdlet name to get detailed information about a specific cmdlet.Get-Help Get-Process
-
Command History: Use the Up Arrow and Down Arrow keys to scroll through previously entered commands.
-
Run as Administrator: Some commands require administrative privileges. Right-click on PowerShell and select Run as administrator.
Conclusion
You have successfully learned some of the most useful PowerShell commands for Windows 11. By mastering these commands, you can effectively manage your system, automate tasks, and troubleshoot issues. Regularly refer to this guide to enhance your PowerShell skills and improve your overall productivity.
Comments
Post a Comment