25 Common PowerShell Command Summary _powershell

Source: Internet
Author: User

Although Windows PowerShell has been on the road for some time, administrators of custom command lines may be interested in understanding the basics of PowerShell functionality.

Let's look at the 25 most common tasks that can be accomplished by Windows PowerShell. Not only are these tasks simple, it is also easy to display the command schema and other PowerShell commands for the statements. Mastering these basic commands is the only way to become a PowerShell expert.

Entry level

1. Operating Windows REGISTRY--CD HKCU like a file system:
2. Recursively search the file for a string--dir–r | Select string "Searchforthis"
  
3. Use memory to find five processes--ps | Sort–p ws | Select–last 5
4. cycle (stop, then reboot) a service, such as Dhcp--restart-service DHCP
5. List all entries in the folder--get-childitem–force
6. Recursive series of directories or folders--get-childitem–force C:\directory–recurse
7. Remove all files in the directory without requiring a single removal--remove-item c:\tobedeleted–recurse
8. Reboot the current computer-(Get-wmiobject-class win32_operatingsystem-computername.). Win32Shutdown (2)

Gather information

9. Get the computer composition or model information--get-wmiobject-class Win32_ComputerSystem
10. Get BIOS information for the current computer--get-wmiobject-class Win32_bios-computername.
11. List the installed hotfixes (such as QFE or Windows Update files)--get-wmiobject-class Win32_quickfixengineering-computername.
12. Gets the user name--get-wmiobject-class Win32_computersystem-property username-computername of the user who is currently logged on to the computer.
13. Gets the name of the application installed on the current computer--get-wmiobject-class Win32_product-computername. | Format-wide-column 1
14. Get the IP address assigned to the current computer--get-wmiobject-class Win32_networkadapterconfiguration-filter ipenabled=true-computername. | Format-table-property IPAddress
15. Get the current machine detailed IP configuration report--get-wmiobject-class win32_networkadapterconfiguration-filter ipenabled=true-computername. | Select-object-property [a-z]*-excludeproperty ipx*,wins*
16. Locate the network card using DHCP enabled on the current computer--get-wmiobject-class win32_networkadapterconfiguration-filter "Dhcpenabled=true"- ComputerName.
17. Enable Dhcp--get-wmiobject-class Win32_networkadapterconfiguration-filter ipenabled=true on all network adapters on the current computer- ComputerName. | foreach-object-process {$_. EnableDHCP ()}

Software Management

18. Install the MSI package on a remote computer--(Get-wmiobject-computername targetmachine-list | Where-object-filterscript {$_. Name-eq "Win32_Product"}). Install (\\MACHINEWHEREMSIRESIDES\path\package.msi)
19. Use an MSI-based application upgrade package upgrade installed Applications--(Get-wmiobject-class Win32_ Product-computername. -filter "Name= ' name_of_app_to_be_upgraded '"). Upgrade (\\MACHINEWHEREMSIRESIDES\path\upgrade_package.msi)
20. To remove the MSI package from the current computer--(Get-wmiobject-class Win32_ Product-filter "Name= ' Product_to_remove '"-computername. ). Uninstall ()
Machine Management
21. A minute later the remote shutdown of another machine--start-sleep 60; Restart-computer–force–computername Targetmachine
22. Add Printer--(New-object-comobject wscript.network). AddWindowsPrinterConnection (\\printerserver\hplaser3)
23. Remove Printer-(New-object-comobject wscript.network). Removeprinterconnection ("\\printerserver\hplaser3")
24. Enter PowerShell session--invoke-command-computername Machine1, Machine2-filepath c:\Script\script.ps1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.