Showing posts with label Windows Server 2012 R2. Show all posts
Showing posts with label Windows Server 2012 R2. Show all posts

Apr 15, 2025

Windows 10/11 : Batch File to Start and Check Windows Services

Create a batch file to check the status of a Windows Service(s) and start it if its not started. The batch file can also be run inside "Task Scheduler" at an interval basis.


1. First, you need to find out the Service Name that you want to monitor, in this example let's say the service you need to monitor is an Exchange Server IMAP4 service.


2. Open --> Services and browse through the list until you found the IMAP4 service.


3. Right-click the Service Name --> Properties.


4. Take note of the "Service name:", copy the name to Notepad. As per below screenshot, the service name is "MSExchangeImap4".



5. Create a batch file as below :-


@ECHO OFF
CLS
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A RETRY_IMAP=0
SET /A MAX_RETRIES=3
SET EXCH_IMAP= MSExchangeImap4

REM To check current status of the service.
:check_imap
SC QUERY %EXCH_IMAP% | FIND "RUNNING" >NUL
IF %ERRORLEVEL%==0 (
    ECHO Exchange IMAP4 Service is Running.
        GOTO end
)

REM To start the service if the status is stopped.
ECHO Exchange IMAP4 Service is Stopped.
SC START %EXCH_IMAP%
TIMEOUT /T 10 >NUL

REM To re-check the service status again for confirmation.
SC QUERY %EXCH_IMAP% | FIND "RUNNING" >NUL
IF %ERRORLEVEL%==0 (
    ECHO Exchange IMAP4 Service is Running.
        GOTO end
)

REM Retrying to start the service with a maximum of 3 retries only.
SET /A RETRY_IMAP+=1
IF !RETRY_IMAP! LSS %MAX_RETRIES% (
    ECHO Retrying Start %EXCH_IMAP% (Attemp: !RETRY_IMAP!).
    GOTO check_imap
) ELSE (
    ECHO Max Retries Reached for %EXCH_IMAP%, will stop retrying.
        GOTO end
)

:end
EXIT



6. You can now test run the batch file and create a "Task Scheduler" to run the check at an interval basis (eg. every 2 hours or at Startup of the server).



!!! HAPPY COMPUTING !!!

Jul 18, 2024

Windows : DISM Error "0x800f081f"

Fixing the DISM Error "0x800f081f". Depending on what you are trying to achieve, in my case is the failure of installing .NET Framework 3.5 in Windows Server 2012 R2 Std 64-bit.

The error message :


Error: 0x800f081f

The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

The DISM log file can be found at C:\Windows\Logs\DISM\dism.log



1. Check the Windows Protected files scan.

sfc /scannow

Results with error :


Beginning system scan. This process will take some time.

Beginning verification phase of the system scan.
Verification 100% complete.

Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.Log windir\Logs\CBS\CBS.log. For example C:\Windows\Logs\CBS\CBS.log. Note that logging is currently not supported in offline servicing scenarios.



2. Scan the image with dism.

dism /online /cleanup-image /scanhealth

Results with error :


Deployment Image Servicing and Management tool
Version: 6.3.9600.19408

Image Version: 6.3.9600.19397

[==============================100.0%============================]

Error: 0x800f081f

The source files could not be found. Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

The DISM log file can be found at C:\Windows\Logs\DISM\dism.log



3. Repairing the files.

dism /online /cleanup-image /restorehealth /source:D:\sources\install.wim /limitaccess


4. Once completed, restart the computer and proceed to install the .NET Framework 3.5

dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess


5. Once done, restart the computer again and the new features is already installed.


!!!HAPPY COMPUTING !!!


May 17, 2023

Multi-Boot USB : Ventoy (Open Source)

Ventoy is an open source tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files.

With Ventoy, you don't need to format the disk over and over, you just need to copy the ISO/WIM/IMG/VHD(x)/EFI files to the USB drive and boot them directly.

You can copy many files at a time and Ventoy will give you a boot menu to select them. You can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disks and boot them.

Supports x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI. Most types of OS supported (Windows/WinPE/Linux/ChromeOS/Unix/VMware/Xen etc.)

Official Ventoy Website : https://www.ventoy.net/en/index.html




!!! HAPPY COMPUTING !!!


May 10, 2023

Windows Server : Install & Configure WSUS (Windows Server Update Services)

 Windows Server : Install & Configure WSUS (Windows Server Update Services).

WSUS is available freely and is part of Windows Server OS (any edition).

Pre-Requisites :

  1. Microsoft Report Viewer 2008 Redistributable (https://www.microsoft.com/en-us/download/details.aspx?id=3203).

Steps to Install WSUS.
  1. Open --> Server Manager
  2. Click --> Add roles and features
  3. Scroll down and Select --> Windows Server Update Services
  4. When Prompted, Click --> Add Features
  5. Continue to Click --> Next
  6. Ensure the following is selected --> WID Database & WSUS Services
  7. Specify WSUS Storage Location (eg. D:\WSUS_Store), ensure sufficient storage spaces is available to store all downloaded updates.
  8. Continue to Click --> Next
  9. Until final Click --> Install
  10. Wait until the Installation Wizard complete.

Post-Installation Steps.
  1. Open --> Windows Server Update Services (available inside "Administrative Tools").
  2. When prompted, ensure the storage location is correct (eg. D:\WSUS_Store), it may a while so please wait until it finishes.
  3. When completed, Click --> Close
  4. Optional to join Microsoft Update Improvement Program, Click --> Next
  5. If this is the first / Primary WSUS, then select --> Synchronize from Microsoft Update
  6. Proceed to configure "Proxy Server" settings (if any).
  7. Next is to connect to Microsoft Update server, Click --> Start Connecting
  8. Once completed, select the language (eg. English) and Click --> Next
  9. Select the products you want to download the updates for (eg. Windows 10).
  10. Next is to select the "Classifications" you want, such as Critical Updates, Security Updates etc.
  11. Configure the synchronization schedules as required.
  12. Select --> Begin initial synchronization
  13. Wait until complete.
 


!!! HAPPY COMPUTING !!!


Apr 21, 2023

Windows Server : Google Chrome Policy for Active Directory GPO

How To add Google Chrome Policy into Active Directory GPO (Group Policy Object).

At times SysAdmin might have the needs to control certain aspect or settings of Google Chrome (such as Start/Home Page), this maybe a tasks too large when your company owns thousands of computers. The most easiest way to deploy the settings via GPO (Group Policy Object) in Active Directory.

This video will show you how to download the Google Chrome Policy (Officially) and deploy it to Active Directory GPO (Central Store) for a much easier and faster deployment, if you find my video useful, please do consider to "Like" and "Subscribe" to my channel (@DanielTechTips), it will means a lot to me. Thanks.



  1. Download Google Chrome Policy.
  2. Extract the download file and search for "windows" folder.
  3. Copy --> "chrome.admx & google.admx" files to Windows Server or to external storage.
  4. Copy also --> "en-US\chrome.adml & google.adml" files.
  5. Copy *.admx files to Windows Server "central store" located at --> %serverlogon%\sysvol\[domain name]\Policies\PolicyDefinitions
  6. Copy *.adml files to --> %serverlogon%\sysvol\[domain name]\Policies\PolicyDefinitions\en-US
  7. Now open --> Group Policy Management
  8. Verify "Google" policy is available for configurations.



!!! HAPPY COMPUTING !!!

Jan 7, 2023

RustDesk : Install RustDesk Server in Ubuntu

 Install RustDesk Server in Ubuntu Server v.22.0.4 64-bit.


1. Check UFW is "Enabled" in Ubuntu.

$sudo ufw status


2. Enable UFW if not available.

$sudo apt install ufw -y

$sudo ufw enable


3. Configure default UFW settings.

$sudo ufw default allow outgoing

$sudo ufw default deny incoming


4. Allow SSH connection.

$sudo ufw allow ssh

$sudo ufw allow 22/tcp


5. Allow RustDesk Ports and Protocols.

$sudo ufw allow 21114:21119/tcp

$sudo ufw allow 8000/tcp

$sudo ufw allow 21116/udp

$sudo ufw allow http

$sudo ufw allow https


6. Install RustDesk Server.

$sudo wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/install.sh

$sudo chmod +x install.sh

$sudo ./install.sh


7. When prompted for IP/Domain Name, key-in a FQDN address. (eg. remote.abc.com)


8. When prompted to install Web Server (HTTPD), type "Yes" (if you haven't install Apache2 Server). It will auto install GoHttpd server (recommended).


9. Upon completion, please take note of the "Public Key, Username and Password" displayed on screen, copy it to notepad for future references.


10. Ensure your router also have "Port Forwarding" configured to match the RustDesk's ports as above.


11. At another computer, open any internet browser (eg. Chrome) and browse to http://[your domain]:8000 and you will prompted for username & password to login, use the same username and password save in above steps.


12. After successful login, proceed to download the installer for Windows, its a PowerShell script. After download proceed to run the script (run as admin).


13. Once installation completed, you can open/run the RustDesk Client on your computer.


Note: as of writing, the "Address Book" function was still under development and there are no timeline available for the release, thus the "Login" function in the "Address Book" module will return an error message.


Edit, 2-Apr-2023: Added Video.





!!! HAPPY COMPUTING !!!



Dec 24, 2020

Windows Server 2012 R2 : Azure AD Connect

 A. Ports requirements.

  1. DNS = 53, TCP & UDP
  2. Kerberos = 88, TCP & UDP
  3. MS-RPC = 135, TCP
  4. LDAP = 389, TCP & UDP
  5. LDAP SSL = 636, TCP & UDP
  6. SMB = 445, TCP
  7. HTTPS = 443, TCP
  8. WinRM = 5985, TCP
  9. Azure Service Bus = 5671, TCP
  10. Dynamic Port Range-RPC = 49152 ~ 65535, TCP (Random High RPC Port)
B. Minimum Hardware Requirements.
  1. Objects < 10,000 = 1.6Ghz CPU, 4GB RAM, 70GB HDD.
  2. Objects 10,000 ~ 50,000 = Same as above.
  3. Objects 50,000 ~ 100,000 = 1.6Ghz CPU, 16GB RAM, 100GB HDD.
  4. Objects 100,000 ~ 300,000 = 1.6Ghz CPU, 32GB RAM, 300GB HDD (required a full fledge SQL server).
C. Microsoft .NET Framework 4.5.1
D. Microsoft PowerShell 3.0 (PowerShell's Transcription Group Policy = Disabled).
E. Microsoft Windows Remote Management for ADFS = Enabled (required SSL certificate for ADFS).

Note: Microsoft recommended to install Azure AD Connect on domain joined server and not on a domain controller server.

But after some testing and installation trials, I found out that installation on a domain controller server is far much more easier to configure. Unsure will there be any security issues, but heck its only a test domain.

!!! HAPPY COMPUTING !!!

Oct 4, 2016

Exchange Server 2013 - POP3 Mail Collector using MDaemon

The new Microsoft Exchange Server 2013 no longer supports POP3 mail collection from a 3rd party hosting provider. It have caused some difficulties for small & medium enterprise where they still replies heavily on this provider for their business email communications.

Some hosting provider does supports IMAP collections while some are not, this is because the server(s) the hosting provider is using was unable to support such protocols (due to whatever the reasons), so you are stuck in the middle to resolve this problems.

So either you change the hosting provider (which may incurred more cost) or you use an old Exchange server that still supports POP3 protocols (which you will not have the latest features & functions).

There are many solutions out in the internet that provide a workaround for this and I find many to be either ridiculous, too little functions/features, too complicated to configured or just plain unstable due to whatever the reasons.

I found that Quantum Software Solutions  Exchange Connector to be the simplest software to use & to configure but due to unknown reasons, the software been giving me a lot of problems lately when my users reached more than 50 users and also I need to constantly monitor the server to manually restart it should it become freezes. It also causes missing emails, unable to send emails to my Exchange server and many more.

So I tried another solution based from my past experiences by using MDaemon Mail Server which I have deployed many times to many clients successfully. And some are still running fine without any problems until today..... now that's what I called stability.

After some trial and error, I have managed to make it work & to cut the story shorts below are some examples of the configurations :-

1. Install MDaemon Mail Server (you may need to check the compatibility list & plan your deployment accordingly). Just follow the on-screen instructions.

2. Goto --> "Setup" --> "Primary Domain" options --> "Domain/ISP" tab as shown below.

a) Domain name = [any local domain name will do, it must NOT be your actual domain].
b) HELO domain = [same as above]
c) Domain IP = [the IP address of the host you are running MDaemon].
d) ISP or smart host's IP or domain name = [your exchange server's IP address].


Note : DO NOT USE your company's actual domain name (eg. company.com.my), you must configure it to use something else (eg. company.local). You will understand why later when I describe how the mail flow works.

3. Goto --> "Ports" tab as shown below and change the "Create outbound SMTP events using this TCP port" option to something that are not standard (eg. 524).



4. Leave the rest configurations as default and click "OK" button.

5. Now goto --> "Setup" --> "Even Scheduling" and configure as shown below then click "OK" button when done.


Note : Some hosting provider limit time access to their server & to avoid lockup, ensure you configure this accordingly to your hosting provider, if in doubt check with them.

6. Now login to your Exchange's ECP, goto --> "mail flow" options.



7. Then goto --> "receive connectors" tab.



8. You will see a list of default transports, click on the plus sign "+" as show below.



9. At the "General" option --> "*Name" box, create a sensible name (eg. POP3 Receive Connector) as shown below.



10. Next goto --> "security" option and ensure its selected as per below options.



11. Then goto --> "scoping" option, configure as below & click the "save" button when done.

a) Ensure the IP address matches your LAN (eg. 192.168.0.*/24).
b) Ensure the port number is specified (eg. 524).
c) Ensure your Exchange server's FQDN is correct (eg. server.company.com.my).



12. Now proceed to logout from your ECP and return back to your MDaemon server, we are now ready to create users for MDaemon (I assume you have already created all the required users in Exchange server).

13. Goto --> "Accounts" menu --> "Accounts Manager" --> click "New" button, then it will display another windows as below. Under "Account" tab configure as shown.

a) Full name = Daniel Cheah
b) Mailbox name = daniel.cheah
c) @ = company.local
d) Account Password = [Password]



14. Browse to "Forwarding" tab --> select "This account is currently forwarding mail" option. Then key-in the FQDN email account (eg. username@company.com.my) as shown below.



15. Next is goto --> "MultiPOP" tab --> select "Enable MultiPOP mail collection for this account" option as shown below.



16. Now type-in your hosting provider's mail server details (eg. pop.provider.com.my) and the username & password (which you have already created in hosting provider's mail server) as shown below, once done click the "Add" button.



17. Once added, you will be able to see the list created as shown below, now click "OK" button to exit.



18. Now you can close all open windows and try send a test email, I will suggest using your own personal Hotmail or Gmail for this testing purposes to ensure MDaemon are able to collect the emails from the hosting provider's mail server and then automatically forward it to your local Exchange server accordingly.

The in your computer, open Microsoft Outlook (which you already configured to connect to your local Exchange server) and check whether you have receive the test email or not. If everything is correctly configured you should be receiving it around 5 mins time.

19. Below is a sample diagram of the incoming mail flow using Quantum Software Solution's Exchange Connector (QSS EC).



20. Below is a sample diagram of the incoming mail flow using MDaemon server.



21. From comparisons both diagram is almost the same but bear in mind that MDaemon is a full fledge server unlike QSS EC which are not.

So how does QSS EC works ?
  1. It collects emails from hosting provider's server via POP3 protocols.
  2. Verify recipients validity by cross checking with Active Directory via AD/LDAP protocols. 
  3. If correct then forward the emails to your local Exchange server via IMAP4 protocols.
  4. Clients collects emails from Exchange server via IMAP4 protocols.
  5. If failed, then it will forward to the "Mail Master/Administrator" mailbox.
This means that QSS EC required constant verifications with AD & Exchange which I suspect was the culprit behind the constant freezes and the "access denied" error in the logs.

22. Now comparing to MDaemon's processing.
  1. Collect emails from hosting provider's server via POP3 protocols.
  2. Verify recipients with MDaemon's local DB (that is why the MDaemon server must not use the same domain name).
  3. Auto forward emails to "Smart Host" (which is your local Exchange server) via SMTP protocols on custom port.
  4. Exchange server verify the recipients & send to local mailboxes.
  5. Clients collects emails from Exchange server via IMAP4 protocols.
As MDaemon is using the "Smart Host" functions to deliver emails to your local Exchange server, the domain name in MDaemon must NOT be the same with your Exchange server. Else MDaemon will thought that this is a local account & no forwarding is required even though you configured it.

23. As for the sending emails out, clients will be using the IMAP4 protocols to send emails to your local Exchange server and then the Exchange server will send the emails out directly. It's the same for both QSS EC & MDaemon.

Of course you can also configured your Exchange server to forward it to your hosting provider's SMTP server and this is up to your decisions. But do keep in mind about the hosting provider's server where it might be lockup due to too many SMTP request from the same IP & thought its was a "spam overflow/DoS" attacks.

That's all and HAPPY EMAILING !!!

Jan 9, 2016

Server - Configuring DNS Forwarder (Windows Server 2012 R2)

The recent changes of TM's (Telekom Malaysia) DNS server IP address to 1.9.1.9 have caused much problems, especially when you have your own domain running in the network.

After much time spend going through Microsoft TechNet & MSDN websites, I have found a simple solution to this.

How it works is that all DNS queries will definitely be going to the local DNS (else your local client will not be able to use the local services provided, such as file & printer sharing), as such local DNS queries will be responded by the local DNS server but other or external queries will return an error.

Now I assume you already have a local DNS server setup & running within your domain, just follow this steps :-

1. Open the "DNS Manager" console, goto START --> Control Panel --> Administrative Tools --> DNS.



2. Right-click on your DNS server and select "Properties" option.


3. Goto "Forwarders" tab and click the "Edit" button.



4. Add the DNS IP address as shown, you can also arrange which is the preferred DNS server by using the "Up" and "Down" button.



5. Once all is done, just click "OK" button to close all open windows. Now it does take sometimes for the DNS server to sync its database so be patient for it. Mine took about 15 mins to 30 mins for it to complete.

If you add an extra DNS server (like me, as I don't want to mess with my AD-DS server), you will also need to ensure that your DHCP server is providing the correct DNS address to all your clients in the network. Below diagram is just an example of how it works :-



Happy Computing !!!