Skip to main content

Posts

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

Test AD account password without logging in to the computer

Documenting AD password is a good practice and should be a part of IT policy. It’s easier to troubleshoot and support users if the password is known to IT. Of course, ethical use of the password should be followed. How to test an active directory account password whether it’s working or not, without logging in or signing in on a computer? PowerShell can help to test a user account password quite easily. AD admin account is needed and the PowerShell must be elevated while running the script below. Correct version of PowerShell is needed for this script. See image below: That’s it! Just replace the username and password to be tested and you can tell your users that the password is not working and needs password reset for their account to work. The script is written for educational purposes and used it ethically. Cheers!! Till next time. Happy Coding!!! ================================ Free Android Apps: ...

Replace column value of text files using awk

AWK is a handy tool to process large text files. Ever came across a need to replace 100 or more text files value in a single column? Of course, the old school method is to do it manually which is definitely time consuming and not efficient at all. Below is a sample code how to replace value in a column for all text files found in the directory specified. #!/bin/bash for file in /home/pc_text/Documents/source/* do xfilename=$(basename $file) #echo "$xfilename" if you need to display the filename while the code is running awk 'FNR==1{print $0}' $file >> /home/pc_text/Documents/output/$xfilename awk 'NR>1{print $1 , $2 , $3 , $4   , "0.873" , $6 , $7 }' $file >> /home/pc_text/Documents/output/$xfilename done Code explanation: for file in /home/pc_text/Documents/source/* - get all text files for processing xfilename=$(basename $file) – get all the filename of the text files awk...

Error: the type or namespace name does not exist in the namespace using visual studio 2017

When compiling an error will occur that a name space does not exist. An example error like the message below: The type or namespace name 'Microsoft.Office.Interop.Outlook' does not exist in   the namespace 'Microsoft'    (are you missing an assembly reference?) The system is trying to find a reference for a specific namespace or dll. One solution for this is to add the reference to the missing namespace. Find the “solution explorer” window like the image below: After opening the “solution explorer” window, right click the name of the project just below the solution explorer. Beside the C# icon. A new window will open like the image below. Click “Add”, then click “Reference”. After clicking “Reference”, the “Reference Manager” window will open. Click “COM” option, then use the filter option to go directly to the desired namespace or reference. Since the error is a Microsoft namespace, type “Microsoft” and “Microsoft...

Copy or migrate shared folders to another server

Migrating or copying files to another server and retaining the permissions is a common task when migrating a file server. If all permissions are successfully retained it will make the migration seamless and nobody will ever notice that a migration has taken place. If there are shared folders and with different permissions, re-sharing the folder by scratch is just time consuming and giving access denied to users will be inevitable. But how to copy files and folders, like it was exactly done on the old server? In Windows environment, just 3 steps are needed. 3 steps sound easy and quick. Steps below will work for NTFS permissions and folder access rights solely depends on it. a.       Copy the files to the new server and retaining its permissions while files and folders are being copied b.       Export the shares registry (old server) c.       Import the shares registry (new server) ...

PowerShell Insert Multiple Lines or text to another file dynamically

Copying and pasting text to another file is a common thing to do, copy and paste done. Boom! In PowerShell scripting copying and pasting text from one file to another dynamically isn’t as easy as it is done in a spreadsheet or document. Dynamically while the code is running  and doing things in the background without human intervention. As the odds say, if there’s a will there’s a way. And making things efficient and easy is a good way in life. If ever a scenario occurs that you need to copy text or lines in a file from one file to another, without breaking the code execution. Script below works just fine. Just insert the code where it is needed. PowerShell code snippet to add lines anywhere on the text file, whether at the top, end or at the middle. #================================ $reader = [ System.IO.File ]:: OpenText( "D:\test-read-paste\main1.txt" ) #get-content can also be used $lineNumberx = 3 #adjust this number where you need to...

PowerShell repeat spaces or characters

Example code of repeating   spaces within a string: $xrepeat = ' ' * 11 $string_with_spaces = “ Hello World of Spaces!!!” Write-output   $xrepeat $string_with_spaces Output image: To indent or tab a string: $Tab = [char]9 Write-Output "$Tab Hello Tab Indention!!!" Output image: To add other HTML character in PowerShell string: $Euro_symbol = [char]8364 Write-Output "$Euro_symbol Hello Euro Symbol in PowerShell!!!" Output image: ================================ Free Android Apps: Click  links below to find out more: Excel Keyboard guide: https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide Heaven's Dew Fall  Prayer app for Android : https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer Catholic Rosary Guide  for Android: ...

Excel Macro get cell values but skip other rows

Raw data that comes in pattern is easy to handle for further processing. For example, if you have a data that has final value in every 7 th row, so basically 1 to 6 is not needed and 7 th row is needed, likewise 8 th row to 13 th row is not needed and 14 th row is needed and the pattern goes on that every 7 th row is the final data from the previous 6 rows. If the pattern continues, it will be like: 1-6, 7 final value, 7 -13, 14 final value, 15 to 20, 21 final value, 22 to 27, 28 final value and the pattern goes on up to hundreds or thousands. It will be time consuming to get every 7th row manually. For graphical representation it will be like: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 From the image above every 7 th row (green color) is needed and the rest is discarded. Other issue comes in if the data has to be processed further in another sheet,...