Friday, 10 April 2020
Sunday, 5 April 2020
POWERSHELL - HOW TO FIND THE UPTIME OF SERVERS VIA POWERSHELL (IN DOMAIN)
POWERSHELL - HOW TO FIND THE UPTIME OF SERVERS VIA POWERSHELL (IN DOMAIN)
We can get the uptime of multiple servers from powershell at the same time. In my example, I will be finding out the uptime of 2 servers which are part of a domain from a single computer.
Please follow the below steps to perform the same:-
1) I have created a text file name Servers.txt which has the name of all the 2 servers and as an example, I am keeping it in C drive which will be restarted.
2) Now I have created a variable $vmlist and will store the contents of the file Servers.txt which is kept on the location C:- Servers.txt. This needs to be done from power shell.
Note:- In my case, I am running from domain administrator account.
3) You can check the Content of the file Servers.txt by running the below command:-
Command:- echo $vmlist
4) Now to find out the uptime of the servers,type in the below command from one of the remote computers. In my example, I am doing it from the DC.
Get-WmiObject win32_operatingsystem -ComputerName $vmlist| select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
Output is:-

We can get the uptime of multiple servers from powershell at the same time. In my example, I will be finding out the uptime of 2 servers which are part of a domain from a single computer.
Please follow the below steps to perform the same:-
1) I have created a text file name Servers.txt which has the name of all the 2 servers and as an example, I am keeping it in C drive which will be restarted.
2) Now I have created a variable $vmlist and will store the contents of the file Servers.txt which is kept on the location C:- Servers.txt. This needs to be done from power shell.
Note:- In my case, I am running from domain administrator account.
3) You can check the Content of the file Servers.txt by running the below command:-
Command:- echo $vmlist
4) Now to find out the uptime of the servers,type in the below command from one of the remote computers. In my example, I am doing it from the DC.
Get-WmiObject win32_operatingsystem -ComputerName $vmlist| select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
Output is:-
POWER-SHELL - HOW TO REBOOT THE SERVERS VIA POWERSHELL (IN DOMAIN)
POWERSHELL - HOW TO REBOOT THE SERVERS VIA POWERSHELL (IN DOMAIN)
We can reboot multiple servers from powershell at the same time. In my example, I will be rebooting 2 servers which are part of a domain from a single computer.
Please follow the below steps to perform the same:-
1) I have created a text file name Servers.txt which has the name of all the 2 servers and as an example, I am keeping it in C drive which will be restarted.
2) Now I have created a variable $vmlist and will store the contents of the file Servers.txt kept on the C Drive which has the names of the Servers which will be re-started. This needs to be done from power shell.
Note:- In my case, I am running from domain administrator account.
3) You can check the Content of the file Servers.txt by running the below command:-
Command:- echo $vmlist
4) Now to reboot the servers,type in the below command from one of the remote computers. In my example, I am doing it from the DC.
Command:- Restart-Computer –ComputerName $vmlist -Force -Verbose
5) Out of running the above command:-

We can reboot multiple servers from powershell at the same time. In my example, I will be rebooting 2 servers which are part of a domain from a single computer.
Please follow the below steps to perform the same:-
1) I have created a text file name Servers.txt which has the name of all the 2 servers and as an example, I am keeping it in C drive which will be restarted.
2) Now I have created a variable $vmlist and will store the contents of the file Servers.txt kept on the C Drive which has the names of the Servers which will be re-started. This needs to be done from power shell.
Note:- In my case, I am running from domain administrator account.
3) You can check the Content of the file Servers.txt by running the below command:-
Command:- echo $vmlist
4) Now to reboot the servers,type in the below command from one of the remote computers. In my example, I am doing it from the DC.
Command:- Restart-Computer –ComputerName $vmlist -Force -Verbose
The Force parameter causes an immediate restart of each computer.
The Verbose parameter tells you what has been done.
5) Out of running the above command:-
VMWARE - HOW TO CREATE A SNAPSHOT FROM VMWARE POWER CLI
VMWARE - HOW TO CREATE AND REMOVE A SNAPSHOT FROM VMWARE POWER CLI
Please follow the below steps to create snapshots via VMware Power CLI.
1) Connect to the VC by running the below command:-
Command:- Connect-VIServer IP Address of the VC of FQDN or the VC.
2) This would prompt you to Enter the Username and Password of the Virtual Center.
3) Once you are connected, it would show you the below prompt:-
4) You can get the list of all the VM by running the below command:-
Command:- Get-VM
5) In my example, I want to take the snapshot of all the 3 VM.
So to perform this, I will create a text file name Servers.txt which has the name of all the 3 servers and as an example, I am keeping it in C drive.
6) Now I have created a variable $vmlist and will store the contents of the file Servers.txt kept on the C Drive which has the names of the Servers for which we want the snapshot.
$vmlist = Get-Content C:\Servers.txt
7) You can check the Content of the file Servers.txt by running the below command:-
Command;- echo $vmlist
8) Now to Create the snapshot you can run the below command:-
Command:- New-Snapshot -VM $vmlist -Name "$($vm.Name)_SNAPSHOT1" -description 'TEST-SNAPSHOT1' -Quiesce -Memory -Verbose
9) The snapshot can be verified by going the going to the VC.
You can also check the same by running the command:-
Command :- Get-Snapshot -VM $vmlist -Verbose
10) You can remove all the snaphsots for the servers - test1, test2 and test3 by running the below command:-
Command :- Get-Snapshot -VM $vmlist | Remove-Snapshot -Confirm:$false -Verbose
11) Now if you run the command to check the snapshots, it would not show you any snap-shot as it has been removed.
Subscribe to:
Posts (Atom)