For Windows 2008
Although Windows powershell has been around for a while, the command line administrator may be interested in the basics of understanding powershell functions.
Next we will look at the most common 25 tasks that can be completed by Windows powershell. Not only are these tasks simple, but the command architecture of the display statement and other powershell commands are also very simple. Mastering these basic commands is the only way to become a powershell expert.
Entry Level
1. Operate Windows registry like a file system --CD hkcu:
2. Search for a string in the file in a timely manner --Dir-r | select string "searchforthis"
3. Use the memory to locate the five processes --PS | sort-P ws | select-last 5
4. Loop (stop, and restart) a service, such as DHCP --Restart-service DHCP
5. list all entries in the folder --Get-childitem-Force
6. recursion of a series of directories or folders --Get-childitem-force C:/directory-recurse
7. Remove all files in the directory without removing a single file --Remove-item C:/tobedeleted-recurse
8. Restart the current computer --(Get-wmiobject-class win32_operatingsystem-computername.). win32shutdown (2)
Collect information
9. Obtain computer composition or model information --Get-wmiobject-class win32_computersystem
10. Obtain the BIOS information of the current computer --Get-wmiobject-class win32_bios-computername.
11. List Installed fixes (such as QFE or Windows Update files )--Get-wmiobject-class win32_quickfixengineering-computername.
12. Get the user name of the user currently logged on to the computer --Get-wmiobject-class win32_computersystem-property username-computername.
13. Get 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. obtain detailed IP Address Configuration Reports for the current machine --Get-wmiobject-class win32_networkadapterconfiguration-filter ipenabled = true-computername. | select-object-property [A-Z] *-excludeproperty IPX *, wins *
16. Find the network card enabled with DHCP on the current computer --Get-wmiobject-class win32_networkadapterconfiguration-filter "dhcpenabled = true"-computername.
17. enable DHCP on all network adapters on the current computer --Get-wmiobject-class win32_networkadapterconfiguration-filter ipenabled = true-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 the MSI-based application upgrade package to upgrade the installed Application --(Get-wmiobject-class win32_product-computername.-filter "name = 'name _ of_app_to_be_upgraded '"). Upgrade (// Machinewheremsiresides/path/upgrade_package.msi)
20. Remove the MSI package from the current computer --(Get-wmiobject-class win32_product-filter "name = 'product _ to_remove '"-computername.). Uninstall ()
Machine Management
21. remotely shut down another machine one minute later --Start-sleep 60; restart-computer-force-computername targetmachine
22. Add a printer --(New-object-comobject wscript. Network). addwindowsprinterconnection (// Printerserver/maid)
23. Remove the printer --(New-object-comobject wscript. Network). removeprinterconnection ("// Printerserver/maid")
24. Enter the powershell session --Invoke-command-computername machine1, machine2-filepath C:/script. PS1
Reproduced on:
Http://www.vmsky.com/tech/Microsoft/win2008/2010/01/08/6686.html