10 PowerShell commands help you manage the remote computer most effectively
Windows PowerShell is a "Command executive" command line system and "Script" scripting language that you can use to manage your system. In the following article, Network Administrator will show you 10 PowerShell commands to manage your computer remotely effectively.
Request:
- Your computer is running Windows Vista (or higher).
- Server running on Windows Server 2008 (or higher).
- PowerShell 5.0.
- Access Admin rights.
1. Create a PowerShell session
Order : Enter-PSSession
For example:
Enter-PSSession -ComputerName REMOTE_COMPUTER_NAME -Credential USERNAME
Creating a PSSession allows an Administrator to remotely connect to another computer on the network and run as many PS commands on that computer as well.
During interaction, many commands can be executed remotely, the reason is because the Admin has the same access interface as they are in front of your computer.
2. Execute the commands
Command : Invoke-Command
For example:
Invoke-Command -Computer REMOTE_COMPUTER_NAME -ScriptBlock {PowerShell Command}
Using the Invoke-Command command on PS will produce the same result as executing a session in command 1 above, but when using Invoke to call a remote command, only one command is executed at the same time. that point.
This is to prevent running multiple commands at the same time, unless these commands are saved as a .PS1 file and Script of these commands is called.
3. Restart the computer
Command: Restart-Computer
For example:
Restart-Computer -ComputerName REMOTE_COMPUTER_NAME –Force
Sometimes in some cases when you install or reconfigure the system to work properly, you will then be asked to restart your computer. Or in some other cases, simply restart your computer to apply the changes, refresh the computer. Then you only need to use a single PS command to execute.
4. Ping the computer
Order: Test-Connection
For example:
Test-Connection -ComputerName DESTINATION_COMPUTER_NAME -Source SOURCE_COMPUTER_NAME
PING is one of the most useful commands in the 'arsenal' of Sysadmin (Systems Admin). Simply enter the PING command and the command will check the connection on the current station on your computer and on another remote system.
Test-Connection will 'raise' the PING command to a new level by 'inserting' it into the PS cmdlet.
Suppose in case you need to check the connection information between the server and the remote device. ICMP requests will be sent from the server to the remote device, but the report is sent back to your admin station.
5. View and edit services
Command: Set-Service
For example:
Set-Service -ComputerName REMOTE_COMPUTER_NAME -Name SERVICE_NAME -Status SERVICE_STATUS
Services are sometimes 'difficult'. Depending on what is happening on a specific computer, the service may 'stop' at the worst possible time. Determining running services with the Get-Service cmdlet command helps you capture the status of the current services.
After you have 'fully grasped' available information, you can set the status for the service - either a service that starts with the letter W or you can set up all services at the same time.
6. Run background tasks (side tasks)
Order: Start-Job
For example:
Start-Job -FilePath PATH_TO_SCRIPT.PS1
Use this command to execute scripts or applications that run in the background without having to log in or perform other tasks. In addition, this command will be executed even if the command fails and does not interrupt the local login of the user on the system.
7. Turn off the computer
Order: Stop-Computer
For example:
Stop-Computer -ComputerName REMOTE_COMPUTER_NAME –Force
Just like other devices, after using your computer you also need to "rest". When performing the shutdown process, you can use this cmdlet to make sure your computer is "shut down" properly.
8. Join the computer to a domain (domain)
Command: Add-Computer
For example:
Add-Computer -ComputerName COMPUTER_NAMES_TO_BE_JOINED -DomainName DOMAIN.COM -Credential DOMAINUSER -Restart
The process of joining a computer to a domain is quite simple, you just need to click 3 times, then enter the full Admin information to finish. However, using this traditional way to join hundreds of domains is extremely time consuming.
In this case you can think of a solution that uses PowerShell. The cmdlet command allows joining multiple computers to one domain (domain) at the same time, and only requires entering the Admin information exactly once.
9. Manage applications and services
Command: Import-Module
For example:
Import-Module -Name NAME_OF_POWERSHELL_MODULE
One of the most outstanding features of PowerShell is managing applications, programs, etc. flexibly, from computer systems to applications like Microsoft Exchange. Some applications and services allow only a certain level of management through a graphical interface. The rest is defaulted to PS management.
This is done through the use of modules that contain the codebase needed to run any PowerShell commands of a particular service or application. Modules are used only when needed, and when they extend PS functionality to a specific service or application. Once completed, you can remove the module completely from the active sessions without having to turn it off.
10. Change the computer name
Order: Rename-Computer
For example:
Rename-Computer -NewName NEW_COMPUTER_NAME -LocalCredential COMPUTERNAMEUSER -Restart
Depending on many factors, including security, company policies, etc., you can rename the computer or not. Either way, the Rename command is useful in working on one or more systems - groups or on a domain.
The command will rename a device and reboot to apply the changes in effect. For a domain, if the Schema Active Directory supports it, the new computers will also be renamed in AD. The object will retain all its settings and join domain status but will display the new name.
Refer to some of the following articles:
- Discover 10 features of PowerShell
- 10 useful basic PowerShell commands for Windows
- About PowerShell
Good luck!
You should read it
- Use PowerShell to download any file on Windows 10
- About PowerShell
- PowerShell command in Windows
- What is PowerShell Basic commands in PowerShell
- How to install PowerShell 7.0 in Windows 10/8/7
- How to use PowerShell's default parameter to change the command behavior
- Instructions on how to use PowerShell in Windows Server 2012
- How are Command Prompt (cmd) and PowerShell different?
- How to check PowerShell version in Windows 10
- How to Run Powershell
- What to do when Windows can't find PowerShell?
- How to Install or Update PowerShell on Windows 11
Maybe you are interested
How to change TikTok name, Tik Tok ID on phone, computer
How to make passport online on phone, computer
5 popular Auto Click software for computers today
Top best mind mapping software on computers and laptops today
How to download Youtube videos to your phone or computer fastest
How to add fonts to Word in Windows computer