Skip to main content

Posts

Showing posts from 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: https://aws.amazon.com/s3/features/ 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 ...

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 ( $disk in $get_disks ){         $get_partitions = gwmi -query "ASSOCIATORS OF {Win32_DiskDrive.DeviceID=' $( $disk . DeviceID) '} WHERE AssocClass = Win32_DiskDriveToDiskPartition"     ForEach ( $partition in $get_partitions ){         $get_logicaldisks = gwmi -query "ASSOCIATORS OF {Win32_DiskPartition.DeviceID=' $( $partition . DeviceID) '} WHERE AssocClass = Win32_LogicalDiskToPartition"          ForEach ( $logicaldisk in $get_logicaldisks ){         $insert_the_dash = ( $disk . SerialNumber) . Insert( 3 , "-" ) #insert dash to match AWS v...

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 $da...

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 roboco...

PowerShell Add Custom Result Property

PowerShell has its own or default format of displaying the results or the output of the cmdlets or PowerShell commands. However, PowerShell is customisable, and the output property can be modified. Example below, gets the name of the file and display the date only without the time. PowerShell code snippet below filter a single  and gets its lastwrite date. get-childitem "C:\Users\ps_testing\Documents" -filter IMXP2611.jpg -recurse |    select Directory, Name, @{Name="LastWriteDate";   Expression={$_.LastWriteTime.ToString("yyyy-MM-dd")}} | ft -wrap This can be modified using wildchars like "*", which filters all "jpg" regardless of filename. get-childitem "C:\Users\ps_testing\Documents" -filter *.jpg -recurse |    select Directory, Name, @{Name="LastWriteDate";   Expression={$_.LastWriteTime.ToString("yyyy-MM-dd")}} | ft -wrap LastWriteDate == is a custom label for the outp...

PowerShell regex count specific character or number

Example input is: 0009911000 $Input_Number = '0009911000' #[1] = tells regex to match on the right or look forward $xtotal=[regex]::Matches($Input_Number,'0+')[1].Value.Length #[0] = tells regex to match on the left or look backward $ytotal=[regex]::Matches($Input_Number,'0+')[0].Value.Length #Matches($Number,'0+') means #Matches($input, $pattern) Write-Output $xtotal Write-Output $ytotal Image output from PowerShell ISE: Above code works or matches if input is something like this: “0009911000” There are zeroes on the left and right and in between are any numbers or characters. For input like this: 0000991100010 in which zeroes are in different position of the string the below code will work. $Input_Number = '0000991100010' $xytotal=[regex]::Matches($Input_Number,'[0]*[0]*[0]+') Write-Output $xytotal Output will be something like this: Groups    : {0000} Success   : True Captures : {...

Print error 016-799 - Fuji Film Xerox

016-799 Fuji Xerox or Fuji Film print error code. That shows a description error as “Print instruction Fail detected in decomposer.” The error code and error description are alien languages for users and even system administrators who are not familiar with Fuji Xerox error code. The error code is quite simple and easy to fix, if the job print goes to the printer but print out doesn’t come out. So, basically the print job was received by the printer, but the printer just doesn’t know what type of paper or what size to use or which tray to utilize for the print out. In some instances, this is just a paper mismatch but the error description; if using Windows 10 to print does not exactly points to what is the issue. First thing to check, is the paper size selected by the user to print. Example, if the printer configuration is A3 and A4 sizes only. But then the person printing the file accidentally chooses “A4 Cover” then this error 016-799 will occur. ...