Useful Powershell Commands for Systems Administrators

Useful Powershell Commands for Systems Administrators

Command
Module/Source Usage  Example
 Add-Printer PrinterManagment Using this command we can printer to the computer  Add-Printer -ConnectionName \\prtsrv\HP3250
 Get-Acl Microsoft.PowerShell.Security  Retrieve NTFS security list  Get-Acl -Path D:\data | FL
 Get-SmbOpenFile  smbshare we can list down all the open files on the server’s share Get-SmbOpenFile
 Get-HotFix Microsoft.PowerShell.Management  List down all the installed windows patches Get-Hotfix
 Close-SmbOpenFile smbshare This command will close all the open files from the network(Network Share).Rather than using file share mmc we can easily close all the files Close-SmbOpenFile
 Get-SmbShare smbshre This command will list down all the shared folders.(Alternative for Net Share) Get-SmbShare
 Get-Printer Print Management List down all the printers in the server or computer. Get-Printer
Get-Process   Microsoft.PowerShell.Management  List down all the running process on the computer Get-Process
Stop-Process  Microsoft.PowerShell.Management  Stop specific process/es on the computer  Get-Process note* | Stop-Process

*With this command i
m going to stop all notepad.exe which are currently running

 Show-EventLog Microsoft.Poershell.Management Run the event viewer(eventvwr.msc) Show-Eventlog

*This command is alternative for eventvwr.msc

 Get-EventLog
 Microsoft.PowerShell.Managemen
 Query/retrieve data from event logs  Get-EventLog -LogName system -InstanceId 20

*This command list down all system system events with event id 20(one of the installation failure event)

Stop-Computer   Microsoft.PowerShell.Managemen  Shutdown the computer Stop-Computer
Restart-Computer  Microsoft.PowerShell.Managemen  Restart the computer Restart-Computer
 Get-VM Hyper-V List down the specific/all virtual machines on the server/Desktop Get-VM

*This will list down all the vms.Also we can filter the data based on name or any other available parameters

Stop-VM  Hyper-V Shutdown the specific/all the virtual machines on the sever/Desktop Stop-VM Srv02

*This will shutdown vm named Srv02

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: