PowerShell is the command line included with Windows. It is a very handy tool for doing simple tasks without the GUI. In this guide, I'll show you 10 tips that will improve your Windows Server experience and make your life easier.
Rather than using the Task Manager or a similar tool, you can use PowerShell to retrieve information about a specific process and kill it, if needed. This will show the process ID (Id ProcessName
):
Get-Process ProcessName
Once you have the process ID of a process, you can kill it:
Stop-Process -id PID
You can actually get the content of a file (for example a .txt
file) and view it in PowerShell:
Get-Content file.txt
You can get information about a certain file with the Get-Item
command. The cool thing about this is that you can use it to return multiple kinds of data, for example, you can see the last time somebody accessed a file:
$(Get-Item D:\Users\William\Desktop\file.txt).lastaccesstime
You can add an Active Directory user with the New-ADUser
command:
New-ADUser -SamAccountName "william" -GivenName "William" -Surname "Edwards" -DisplayName "William David Edwards"
Removing an Active Directory user with PowerShell is possible too:
Remove-ADUser William
You can use a DN, SAM account name, SID, or an object GUID here.
You can add an Active Directory group with PowerShell very easily:
New-ADGroup âname Staffâ âgroupscope Global
Use the name of the new Active Directory group for -name
and change the group scope if needed.
Likewise, you can also remove an Active Directory group with PowerShell:
Remove-ADGroup Staff
You can find all domain controllers in a domain with PowerShell by finding out which computers are in the Domain Controllers group:
Get-ADGroupMember 'Domain Controllers'
You can disable an account in Active Directory to prevent a user from logging in. This can be done from PowerShell to avoid having to use the GUI for this simple task:
Disable-ADAccount William
Again, you can use a DN, SAM account name, SID, or an object GUID here.