Skip to main content


Showing posts from November, 2019

Copying files in AWS S3 bucket

Learning to copy files to S3 bucket or from S3 bucket to local folder is a must thing to learn when administering S3 bucket.
S3 bucket is an object storage.See details on this link:
An S3 policy called WORM (write-once read-many) policy can be enforced to S3 bucket.
WORM is ideal for log files.Backup or write the log file once and read it many times if someone needs to read or review the logs.
Let’s get into business, how to copy files to S3 bucket?
S3 is an acronym for Simple Storage Service.
S3 accepts Linux command, so if you are running Windows be careful when typing S3 commands.
A simple mistake of running Capital letters can ruin your day since the command will not work and the error won’t be friendly to tell you that it was just a simple mistake that you just type in capital letter.
Copying is plain simple, so here’s a basic and simple example:
aws s3 cp test_bucket.txt s3://thes3bucket
s3 – is small letter it’s not S3. If S3 is typed on the command l…

PowerShell Match Drive Letter to Volume ID in AWS

Matching AWS volume ID to its corresponding Windows drive letter is an easy task using PowerShell.
Win32_DiskDrive holds the info for the volume-ID.
Here’s the script, below enjoy 😊

$get_disks=gwmi-query"SELECT * FROM Win32_DiskDrive"
ForEach($diskin$get_disks){ $get_partitions=gwmi-query"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} WHERE AssocClass = Win32_DiskDriveToDiskPartition"
$get_logicaldisks=gwmi-query"ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} WHERE AssocClass = Win32_LogicalDiskToPartition" ForEach($logicaldiskin$get_logicaldisks){
$insert_the_dash= ($disk.SerialNumber).Insert(3,"-") #insert dash to match AWS volume
$volume_partition="Drive Letter "+$logicaldisk.DeviceID +"is equals to volume: "+$insert_the_dash
Write-Output$volume_partition } }

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
#subtract the current date and time with the boot time $get_duration=$Date-$xtime $xmin_total=$get_duration.TotalMinut…