Skip to main content

Posts

Showing posts with the label CMD

PowerShell check Windows boot time and uptime

Checking boot time is essential in determining the server or workstation uptime.
If ever there is a server or computer that is not supposed to be rebooted or shutdown but then to check whether the server or computer hasn’t done a power cycle is to check its uptime.
Checking the uptime will determine how long the server has been online.
PowerShell is just an awesome tool to do this kind of task.

Here’s the script:
#run a command line using PowerShell $boot_time=&systeminfo|find"System Boot Time" Write-Output$boot_time
#display a pop-up message box using PowerShell [System.Windows.MessageBox]::Show('Hello, the '+$boot_time)
#split string using regex and match spaces $splitx=$boot_time-split'\s+'-match'\S'
#get the 4th array on the array element $xtime=Get-Date$splitx[4]
#get the current date and time of the system $Date=Get-Date
Write-Output$date
#subtract the current date and time with the boot time $get_duration=$Date-$xtime $xmin_total=$get_duration.TotalMinut…

Robocopy backup using Task Scheduler

Backup is a simple word that has a very good significant value in today’s digital world.

Unattended backup or automated backup is a good strategy, so the user or the whoever is managing the backup won't need to manually trigger the backup.
No data backup is a head-on strategy, that leads to catastrophe.
Backup is very, very important in today’s digital world. You will never know when a data disaster will strike.
The whole laptop will be lost, the hard drive will fail without any sign, a virus might corrupt the whole system or just simple mistake to overwrite or delete a data. All this scenario requires a backup rescue to recover the data.
Robocopy is a built-in command in Windows that does a pretty awesome job to backup or copy files.
Using Windows task scheduler, robocopy and Vbscript will create an important task to backup data.
How the three tools will be used, to backup data?
Robocopy – to backup or copy the files Vbscript – to hide the robocopy in the background while Roboc…

Backup SystemState Windows Server to a network share

Backup SystemState of a server to a network share is preferable rather than backing up to another partition within the local server.
Backing up to a network share is quite a good practice, so just in case anything goes wrong to the local server the system state is still safe since the backup is on a network share.
So, it’s like the old adage. Don’t put eggs in one basket. If all eggs are in one basket and if the basket is broken then everything is gone. Same logic goes to a server backup, protecting a server with a backup but then putting the backup to a local partition does not really protect the server from hard disk failure.
How to backup system state using wbadmin to a network share?
It’s quite straight forward but command prompt must be run at an elevated mode, and a network share that is accessible by the server and has enough space to hold the backup.
Command below will work with Windows 2008 and Windows 2012; newer version of Windows may still work but not tested.
wbadmin star…

Empty log or replace large files

Log files can easily occupy the space of a drive.

If the log files is collecting or monitoring multiple system then chances are it will grow in size very quickly.

If it the log file is in a text format, even if it comes in Giga or Tera bytes size it can be emptied very quickly in a command line.

If the log files has been analyzed or not in use anymore, then it is a good candidate to get rid of it rather than occupy the space of a drive for nothing.

To empty a log file or a text file:

In Windows open command prompt and type:

echo "First Line" > Packets_2018.log

The log file will be replace with the word "First Line" and only a few bytes in size. Whatever was the content before on that log file is ditch away. So, be careful in emptying a file it's not reversible,

In Linux open Terminal and type:

echo "Line 1" > Packet_logstash.log

Till next time..Cheers!

================================ Free Android Apps:
Click  links below to find out more:
Excel Keyb…

Add multiple drivers to a WinPE image

How to add multiple inf drivers to a Windows PE Image?

To add a single driver to a Windows PE Image  is quite straight forward but adding multiple drivers  one by one is not ideal or else it will take a definite amount of time.

Dism command provides an option to add a single driver or add multiple drivers.


To add a single driver or multiple drivers, the first thing to do is to mount the image for editing.

Dism /Mount-Image /ImageFile:"C:\WinPE_amd64\sources\boot.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount"

C:\WinPE_amd64\media\sources\boot.wim -  is the image where the new drivers will be added

C:\WinPE_amd64\mount - this directory will contain the extracted files of wim images, the folder must be created if it doesn't exist

Once the image has been mounted, to add a single driver type the command below:

Dism /Add-Driver /Image:"C:\WinPE_amd64\mount" /Driver:"C:\Folder_Driver\driver.inf"

C:\WinPE_amd64\mount - the folder in which the mount i…