Top 25 Windows PowerShell Commands for Administrators

January 11, 2017 | Author: Paul Watson | Category: N/A
Share Embed Donate


Short Description

Download Top 25 Windows PowerShell Commands for Administrators...

Description

Top 25 Windows PowerShell commands for administrators

by Jonathan Hassell The Sun Valley Group, Inc.

Getting started with PowerShell or just need a quick refresher? This tip lists the most common PowerShell commands, with details on when to use them. THIS ARTICLE COVERS

File Management RELATED TOPICS



Backup and Data Protection



Data Recovery



Tools and Utilities



DAS



Disaster Recovery



Network Storage LOOKING FOR SOMETHING ELSE?



Troubleshoot Windows Server file copy errors



Use a PowerShell FTP script to upload and download files



Can admins change the write back cache size? TECHNOLOGIES

Systems management PRODUCTS

Windows PowerShell

In this Article 

Common entries (just to get started)



Collecting information



Software management



Machine management



Dig Deeper

Related Content 

How to use WMI with Windows PowerShell scripts – SearchWindowsServer



How to manage Windows services using PowerShell – SearchWindowsServer



Windows Server 2008: PowerShell basics and top ... – SearchITOperations

   

 

Sponsored News 

Why Hybrid Cloud Object Storage Deployments Require Flexibility –IBM



Top 3 Things to Look for in a Virtualized Storage Solution –Dell



See More

Vendor Resources 

Managing Active Directory Users and Computers with Windows PowerShell for ... –Veeam Software



Expert Insight into Powershell's Scripting –Dell Compellent

Even though Windows PowerShell has been around for a while, administrators who are brushing up on their command line skills may be interested in understanding the fundamentals of its capabilities. Let's take a look at 25 very common tasks you can accomplish with Windows PowerShell. Not only are the tasks themselves common, but the structures of the commands show off the syntax and structure of other PowerShell commands, as well. These basic commands should get you started on the path to becoming a PowerShell master.

Common entries (just to get started) 1. Navigate the Windows Registry like the file system -- cd 2. Search recursively for a certain string within files -- dir "searchforthis"

hkcu:

–r | select string

3. Find the five processes using the most memory -- ps

| sort –p ws | select

–last 5

4. Cycle a service (stop, and then restart it) like DHCP -- Restart-Service 5. List all items within a folder -- Get-ChildItem

DHCP

– Force

6. Recurse over a series of directories or folders -- Get-ChildItem

–Force

c:\directory –Recurse

7. Remove all files within a directory without being prompted for each --RemoveItem C:\tobedeleted –Recurse

8. Restart the current computer --

(Get-WmiObject -Class Win32_OperatingSystem

-ComputerName .).Win32Shutdown(2)

Collecting information 9. Get information about the make and model of a computer -- Get-WmiObject -Class Win32_ComputerSystem

10. Get information about the BIOS of the current computer -- Get-WmiObject -Class Win32_BIOS -ComputerName .

11. >List installed hotfixes (QFEs, or Windows Update files) -- Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName .

12. Get the username of the person currently logged on to a computer --GetWmiObject -Class Win32_ComputerSystem -Property UserName -ComputerName .

PRO+

Content Find more PRO+ content and other member only offers, here. 

E-Handbook

Determining the right time for a Windows Server 2016 upgrade

13. Find just the names of installed applications on the current computer --GetWmiObject -Class Win32_Product -ComputerName . | Format-Wide -Column 1

14. Get IP addresses assigned to the current computer -- Get-WmiObject

-Class

Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Format-Table -Property IPAddress

15. Get a more detailed IP configuration report for the current machine --GetWmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property [a-z]* -ExcludeProperty IPX*,WINS*

16. To find network cards with DHCP enabled on the current computer --GetWmiObject -Class Win32_NetworkAdapterConfiguration -Filter "DHCPEnabled=true" -ComputerName .

17. Enable DHCP on all network adapters on the current computer -- GetWmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=true -ComputerName . | ForEach-Object -Process {$_.EnableDHCP()}

Software management 18. Install an MSI package on a remote computer -- (Get-WMIObject -ComputerName TARGETMACHINE -List | Where-Object -FilterScript {$_.Name -eq "Win32_Product"}).Install(\\MACHINEWHEREMSIRESIDES\path\package.msi)

19. Upgrade an installed application with an MSI-based application upgrade package -- (Get-WmiObject -Class Win32_Product -ComputerName . -Filter "Name='name_of_app_to_be_upgraded'").Upgrade(\\MACHINEWHEREMSIRESIDES\path\upg rade_package.msi)

20. Remove an 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 after one minute -- Start-Sleep

60;

Restart-Computer –Force –ComputerName TARGETMACHINE

22. Add a printer -- (New-Object

-ComObject

WScript.Network).AddWindowsPrinterConnection("\\printerserver\hplaser3")

23. Remove a printer -- (New-Object

-ComObject

WScript.Network).RemovePrinterConnection("\\printerserver\hplaser3 ")

24. Enter into a remote PowerShell session (you must have remote management enabled) -- enter-pssession TARGETMACHINE 25. Run a script on a remote computer -- invoke-command

-computername

machine1, machine2 -filepath c:\Script\script.ps1

Windows Scripting School  Need to bone up on your scripting know-how? It's time to go to school. Check out the archives from Christa Anderson's scripting column.

ABOUT THE AUTHOR Jonathan Hassell is an author, consultant and speaker residing in Charlotte, N.C. Jonathan's books include RADIUS, Learning Windows Server 2003,Hardening Windows and most recently Windows Vista: Beyond the Manual. This was last published in September 2009

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF