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
- 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
May be interested
- How to install PowerShell 7.0 in Windows 10/8/7powershell 7 is the latest major update for powershell. powershell includes command line shells, object-oriented programming languages, along with a set of tools for script / cmdlet execution and module management.
- How to create and run a PowerShell script file on Windows 10a script is a collection of commands stored in a text file (using the special extension .ps1) that powershell understands and executes step by step to trigger a variety of operations.
- PowerShell and everything you need to know about itwhat is powershell? microsoft powershell is a command line utility and scripting language that is a powerful tool for administrators that helps you automate a wide range of computer and network tasks.
- 10 useful basic PowerShell commands for Windowsover the past few years, microsoft has tried to turn powershell into one of the comprehensive management tools for windows.
- Run remote commands on Cisco routers from the computercan you place the cursor at the windows command prompt and run a command on the router? usually, you will first have telnet or ssh to connect to the router to be able to execute commands? this article will show you how to simultaneously run router commands without having to exit the windows command prompt, which is very convenient for control and
- What is Windows PowerShell? How to use Windows PowerShelldo you want to learn the features of windows powershell but don't know how? suggestions for you what is windows powershell? the most convenient way to use windows powershell.
- How to add the Open Powershell Here option to the context menu on Windowsto open and use powershell faster and simpler when needed, you can add the 'open powershell here' option to the context menu - the menu when you right-click. in the following article, network administrator will show you how to add the 'open powershell here' option to the context menu on the windows operating system.
- Server administration in Exchange 2007 using Powershellin this article, i will show you the database and the problem of managing storage groups using the commands in powershell.
- 10 tips with PowerShell in Windows Server 2008 - Part 1in fact, there are a lot of windows server 2008 tasks that we can do a lot faster with powershell than the gui-based application or tool. in the following article, we will introduce you some basic and most frequently used operations with powershell ...
- Top 15 free remote computer control toolsremote computer control software allows users to control a remote computer with another computer. it is really useful when technical support, file transfer, etc. this article will introduce you to the top 15 best free remote computer control software in 2017.