Skip to main content

Posts

Showing posts with the label Windows Server

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…

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)
The link below from Microsoft website shows how xcopy can copy folder and retain the permissions.
https://support.microsoft.com/…

PowerShell repeat spaces or characters

Example code of repeatingspaces 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:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html

Working with text in PowerShell

Working with a text file or text format in PowerShell is a good thing to learn.
Getting or monitoring output from PowerShell for further processing or analysis and having it in text file format can easily be imported to other applications.
Working with text or other format, requires these basic operations: Save, Overwrite, Append and Save As.
Save, overwrite, append and save as is a common operation when editing word documents, excel file and other office applications since it’s freely available on the menu of the application. But can we do this in PowerShell? The answer is a resounding, yes.


So, how to do it? Examples below shows how to work with text files in PowerShell and do the operation mentioned above.

Equivalent operations for Save, Overwrite, Append and Save As in PowerShell:
===Set-content ==== will overwrite the file ===Add-content ==== will just add or append something to the file ===Out-File ==== is like "Save As" since you have the option to save the file to a…

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…

Linux copy files and change date or time

So, you want to copy files from one folder to another folder and change both the source and destination timestamp?
Linux can easily change or modify the timestamp with ‘touch’ command.
A one liner command with the help of ‘pipe’ to pass the arguments and ‘xargs’ to execute multiple commands in a single line can easily accomplish this task.
Command below will copy the files in the current directory where ‘ls’ command is executed to the directory ‘xfiles’, timestamp will be changed to 7 hours less from the current time.
ls | xargs -I % sh -c 'touch -d "7 hours ago" %; cp -p % ./xfiles';
-p option is important to preserve the modified timestamp
Note: the above command will change the timestamp for both source files and destination files.
Command below will change the source timestamp, but the destination timestamp will be the date and time that the command was executed.
ls | xargs -I % sh -c 'touch -d "2 Aug" %; cp % ./x';

Notice, that the -p option is omitted …

WSUS – quick installation guide

WSUS or Windows Server Update Services is patching system for Windows OSes and other Microsoft products.
In Windows 2016 or another version of Windows server it’s quite straight forward to install or config ure WSUS. Make sure the server has enough memory and has sufficient space to download and store updates.
Plan accordingly the computer groups in WSUS, like 1 group for Testing updates and 1 group for production or other methods or strategy that is right for the environment.
Configuring WSUS should be straight forward but in some instances, it may not work right after installing the WSUS server role.
First, install and configure WSUS server role.
Second, configure GPO to point to WSUS server. If the clients will not know where to find or report to a WSUS server then WSUS sever will be empty. WSUS server will not be able to detect client or server devices.
In GPO you need to set the settings of how you are going to carry out the updates, like the time to install the updates, and a notific…

Activate Windows from command line

How to activate Windows from command line?
If you have decided to convert an evaluation Windows server (Windows 2016 or other server version), or Windows 10 to a license Operating system then you need to replace the product key. You will need to change the product key and activate the system, in order to use the product outside of its evaluation period.
Assuming you have done the steps of converting the evaluation software and all the evaluation packages has been removed. Of course, if you have plenty of time in your hands and you just want to redo everything then you can just install or setup a new environment.
To activate a new product key from command line, first the product key must be installed and replaced the existing one. Second, activate the product key.
Here’s how to do it via command line:
a. slmgr /ipk windows-product-key-with-slashes
/ipk = installed product key windows-product-key-with-slashes – replace this with the actual windows product key
If everything goes well there will b…

PowerShell search files/folder names with regex

Searching files with regex will come in handy provided you know the pattern you want to look for.
Searching for files that you don't have any clue or idea which one to find is such a dreadful situation.
Regex will help to filter files base on the pattern set from a fragmented memory due to multi-tasking world.
For example, you are quite sure that the file you're looking for starts with s and followed by letter k.
So files like skype_password.txt, skew animation.mp4, skbanner.logo, skin.css, skilled-listing.docx or any files that begins with "sk" will be filtered.
Here's the PowerShell code to do it:
#===================
$regx_filters = get-childitem "c:\all_files_n_rumble\" -recurse | where-object {$_.name -match '^s[k]' } Write-Output $regx_filters
#===================
To get folder or directory names with regex:
#===================
$regexPattern ="^l[i]" Get-ChildItem -Path "c:\all_folder_n_mixes\" -Recurse | Where-Object {$_.PS…

How to escape in PowerShell

In bash script the backslash is use as escape sequence and even in Java programming.

But what's the equivalent of bash escape sequence in PowerShell?

Grave accent or back tick, which is found at the top left corner of the keybord below the "esc" key on some keyboard, This character "`" is the escape in PowerShell.

For example:

Write-host "This line is above `r`n and  `r`n this line is below"

Output is:
This line is above
 and
 this line is below

r is equal to carriage return character putting a backtick before r, `r tells PowerShell that r is not a character but a carriage return
n is a new line character putting a backtick before n, `n tells PowerShell that n is a new line character.

Another example:

$ sign in PowerShell is to indicate a variable

But what if you need to display a dollar sign as a character and not as a special character to declare a variable. Then we need to escape the dollar sign by prefixing a backtick before the character.

Exampl…