Skip to main content

Posts

Plesk : How to create banner notification in plesk

 Today we will learn how to post banner notification in Plesk -Windows. This is useful when you want to display a specific content like new features or downtime message in the homepage of customer panel. We will be using the plesk extension - Broadcast message to achieve this task. To install the extension : C:\> plesk bin extension --install broadcast-message Turn on the extension : C:\> plesk db "update ModuleSettings set value = 1 where name = 'enable' and module_id in (select id from Modules where name = 'broadcast-message')" Turn off the extension : C:\> plesk db "update ModuleSettings set value = 0 where name = 'enable' and module_id in (select id from Modules where name = 'broadcast-message')" Edit the notification text: C:\> plesk db "update ModuleSettings set value = '<new message>' where name = 'message' and module_id in (select id from Modules where name = 'broadcast-message')

Powershell : How to find if a software is installed or not

Task is to write a Function in Powershell which can be used by multiple boxes to find if a software is installed or not. SCRIPT

PowerShell Tip : How to fetch XML Event Data log using Powershell

  So Today, one of the member of our PowerShell Forum asked me the question - How to Fetch the XML Event Data like Prop_DeviceName , Prop_ContainerID etc of a specific event ID 112 from the event log. So here is the solution for the same. In this example we will use the cmdlet Get-WinEvent and will try to grab the details. CODE : Get-WinEvent -FilterHashtable @{Logname="Microsoft-Windows-DeviceSetupManager/Admin";Id=112} -MaxEvents 1 | %{ $eventXml = ([xml]$_.ToXml()).Event $eventXml.EventData.Data } OUTPUT : You can modify the script as per your need. Happy Learning!

Mailenable : Webmail showing Server communication failure

  Many Mailenable users are familiar with the error " Server communication failure. Please refresh your browser and try again. ". This error shows when you try to send an email using Mailenable webmail. In today's lesson, we will learn how to fix this. In general, there are two ways to resolve this problem: STEP 1 : The Mailenable webmail is mostly compatible with 32-bit applications written in .NET 2.0. To begin with, you can try this. Just go to MailenableAppPool and in Advanced settings change the .NET version to 2.0 and 32 bit as TRUE. STEP 2 : If the .NET version is already 2.0 and the error still occurs, then follow these steps. Go to Mailenable Bin path Search for " MeInstaller.exe " file > Run it as Administrator Now Select Option 13. Set .Net Framework version for web application > Next Now it will ask for the ASP.Net configuration details and select the appropriate one you want to use > Execute Hopefully, this will fix the problem.

How to fix Trust Relationship issue in Windows (without System Reboot)

  Hello Readers, today we are going to learn how to Fix trust relationship issue between the workstation and the domain. But before jumping into the solution, we need to learn the concept of Secure channel. What is a Secure Channel ? Before understanding the trust relationship issue, you will need to know what is a Secure channel .  Whenever you add a computer or client machine to an Active Directory domain, your computer account gets created in Active Directory. Secure Channel helps to make the communication between the client machine and DC (Domain Controller), Example : Replicating Group Policies. Always remember in a Secure channel the computer authentication takes place and not the User Authentication So for this Authentication Password is required. Once computer is joined to the domain a password for authentication is proposed to the Active Directory By Default, Computer account password change is initiated by the client computer in every 30 days . This can be modified in Group P

GIT : How to remove untracked files in git

There might be several conditions where you have started editing a file in git but then you realize its not needed any more and want to roll it back.  Such files will be showing in untracked files list in git as show below when you run git status command. Today we will learn how to remove such untracked files in git.  To fix it you can run the below command :  git clean -f 

Linux Tip : How to fix Route issues

Today we are going to learn how to fix route issues on Linux. Suppose you have 2 NIC interface (one is for public traffic - 100 GBPS Link and other one in Private interface for private communication 10 GBPS Link ). What is the exact issue ? Initially our customers reported that they were unable to reach internet on the box (They tried performing ping 8.8.8.8 -or- ping google.com). It was not working via both IP and domain name even tried with browser. So lets begin the troubleshooting : Step 1 : Replicate the issue from your side, because we need to be 100% sure before deep diving. Step 2 : We were able to replicate the same. It was 100% packet loss. So now we need to check if the public interface is up and running or not . Our public interface is eth1 so run command : ip a This will show you if interface is UP / Down. Eth1 was up and running here. Step 3 : Next I was interested to see how is the traffic going out - is it crossing any single hop or not , whether Gateway is reachable

Linux Useful commands

Here are the list of some useful Linux commands that's used on a day-to-day work and are equally important for interview purposes.  1. How to check memory usage free -h -h is to make the result readable by humans. 2. How to check disk usage df -h 3. How to check CPU Usage top 4. How to quickly find the process id of a program pgrep <ProcessName> 5. How to find the Linux Kernal version uname -r amar@LPF22E8MA:~$ uname -r 4.4.0-19041-Microsoft 6. How to find the Operating System (OS) version cat /etc/os-release lsb_release -a amar@LPF22E8MA:~$ cat /etc/os-release NAME="Ubuntu" VERSION="20.04 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_C

PowerShell Tip : How to copy a file remotely using WINRM

Today, we are going to see how to copy a file to remote destination using WINRM. Traditionally SMB Protocol (File Sharing \\Servername\C$) was used to transfer the files but nowadays you will find SMB Protocol disabled on some servers so you will require firewall changes to perform that.  On the other hand WINRM Protocol 5985 is mostly open for Powershell Remote sessions, so we will use that to transfer the files. Lets get started : Step 1 : Create a PS Session for that server  $Session = New-PSSession -ComputerName <ServerName> Step 2 : Use Copy-Item with -ToSession to transfer the file using WINRM Copy-Item -Path C:\Scripts\Amar\TestFile.txt -ToSession $Session -Destination "D:\" TestFile.txt file will get copied from local system to the D Drive of the remote server. Happy Learning :)

ActiveDirectory : How to find unused AD User accounts using Powershell

Today we are going to learn how to remove an AD User which is not Active since a long time lets say 1 year. As a part of Server hardening best practices, you should always run checks to remove the disabled or orphan accounts from Active directory. We will be using the Active Directory module in Powershell to perform the activity : CODE :  $Date =(Get-Date).AddDays(-365) Get-ADUser -Filter 'LastLogondate -le $Date' -Properties LastLogonDate | Select Name, LastLogonDate To remove the ADUser use : Remove-ADUser -Identity "<SamAccountName>"

Linux Tip : How to Switch user as root if you have Sudoers access

Today we will see how one can become a root user if he / she has sudoers access. In some organizations if you try to switch user to root ( sudo su - root ), you may see error like below : Sorry, user <username> is not allowed to execute '/bin/su - root' as root on <hostname> But you can try other method to switch as root user. Lets look into those steps. Method 1 : Type  sudo vi -c '!bash' in the command line console and that's it. Method 2 :   Type   sudo vi a.txt  in the command line console , it will open vi editor just press ESC (Escape) and then :sh and Enter Hope you all enjoyed this little hack, do share your queries in the comment box below.

PowerShell Tip : How to find Host node name from inside the VM

Let's assume a scenario where you are inside the Virtual Machine but you want to the know the Host node name. Unless you maintain some inventory management system, it would be a troublesome job to identify the same. Here is how this can be achieved using Powershell. Just run the below one-liner on the VM : (Get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")

Kubernetes and Docker Notes

What is Kubernetes ? Kubernetes (K8s) is a container orchestration tool, which helps to manage, deploy and scale containers like Docker etc. Kubernetes was designed by Google using Go Lang. What is Docker ? Docker is an open source project that automates the deployment of applications inside containers. What are Containers ? ⚡Containers are basically layer of Base image and application image, stacked together with all their necessary dependencies and configuration. ⚡Containers are portable and scalable.  Docker Public Repository :   https://hub.docker.com/ How to install Docker on Windows  ? Note : Hardware Virtualization should be enabled on the host box in order to install Docker.  1. Go to the link =  https://docs.docker.com/desktop/windows/install/ 2. Download and Install the application To verify if installation was successful or not, just type :  docker run hello-world while running the above command I got the below error, it was because I didn't run Docker desktop app with

Powershell Tip : How to fetch public ip using Powershell Console

There are several ways to fetch your public ip like below : But today we are going to see the simplest way to fetch the same via Powershell console : Command : (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content

How to check if SPF Record is valid or not ?

Before starting, lets understand what is SPF Record and its uses ? SPF Record is a Sender Policy Framework record. It is used by the mail servers to identify if the mails are coming from an authorized hosts or not. This helps to prevent spammers from sending mails using the Fake From address of your domain. Always avoid to keep multiple SPF Records for a domain. You can use the below domains to create or check if SPF Record is valid or not : 1. Create and check SPF record online (spf-record.com) 2. Free SPF Record Checker - Check SPF Record - SPF Record Lookup - DMARCLY 3. SPF Query Tool (kitterman.com)

How to see remote changes before doing Git Pull

Before going through the steps, lets first understand what is the purpose of GIT Pull ? In simple terms, GIT PULL is a GIT Command which access the Remote repository and checks which all files were modified or created and is different from the local repository. Once it finds that info, it downloads those file to your local repository.  Technically speaking, GIT Pull runs 2 commands i.e GIT Fetch and GIT Merge in background. GIT Fetch downloads the latest change to the local repository while GIT Merge merges the remote content refs and heads to new local merge commit. so you can say the below is same : GIT Pull <remote> -or- GIT Fetch <remote> GIT Merge origin/master So lets begin with the steps on how to see the remote (origin/master) changes before doing Git Pull :  Git fetch origin Git log master..origin/master Git diff master..origin/master Git pull / Git merge origin/master Happy Leaning! How to get started with GIT in Windows : Check out here

Powershell Tip : How to find the IP Address of a VM from a HyperV

Today we are going to see how to fetch the IPv4 Address details of a VM from a HyperVisor console. We will be using Powershell to achieve the same with a One-Liner code.  You can modify the Command as per your need. Our requirement is to check Only the Running VM's and  get the VM Name and its corresponding IPv4 Address. So lets get started. CODE (Execute in HyperV ): Get-VM | ? State -eq "Running" | select Name, @{l="IPv4Address";e={($_.NetworkAdapters.IPAddresses -match "(?<Address >((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))")} } CODE DETAILS : 1. Get-VM : Fetches the VM List present on the HyperVisor 2. ? State -EQ "Running" : It is similar to Where-Object {$_.State -eq "Running"} , here we are using where-object to fetch only the Running VM list from the Pipeline. 3. NetworkAdapters properties of the VM Contains the IPAddresses information, we are using IPv4 address Regex to get

Disposable Phone Number website list to receive OTP Messages

Here’s the List of website from where you can get several countries disposable phone numbers which you can use to retrieve messages like OTP and so on. List of websites who provide Disposal Numbers : receivesmsonline.net receivefreesms.com freeonlinephone.org receive-sms-online.com sms-receive.net sellaite.com receive-sms-now.com receive-sms-online.info hs3x.com smsreceivefree.com receivesmsonline.com freesmsverification.com receiveasms.com Note : Don’t use this websites for any kind of illegal activity, since logs are maintained everywhere.

Powershell Tip : How to Change the Error Foreground Color in PowerShell

For one or the other reason we sometimes don’t like the "Red colored ERROR" which we used to get when we come across some error in powershell like below : So lets change this red color shown in the console, although its of no use(i.e technically speaking, it will work in the same way) but still just for learning purpose lets do it. In order to make this ERROR Foreground as any other color(over here green), write the below command in the Powershell console. $Host.PrivateData.ErrorForegroundColor = "Green" Output : Quite interesting right, Not only this you can change colors of several properties like Warning, Debug, Verbose etc. Just run  $Host.PrivateData | get-member Hope you all enjoy this Post, Do Like, Share and Comment if you have any suggestion or queries.

Plesk Tip : How to Find cron or task scheduler details of a specific Customer

Tested on : Plesk Obsidian, Windows 2012 R2 Few days back i was looking into a way to find the cron details of a customer and once its fetched remove the crons created by that user. Through GUI, it can be done in 2 ways : 1. Go to Tools & Settings > Scheduler Tasks -or- Domains > Schedule Tasks 2. Login to the server > Open Task scheduler (taskschd) and Look into the task with description. You will get the domain id there But the above mentioned process is quite cumbersome. So after digging a lot, I was able to figure it out using Powershell. To get all the cron details of a particular Customer : & "$Env:Plesk_Bin\Crontabmng.exe" get "CustomerName" To Remove all the crons of a particular Customer : & "$Env:Plesk_Bin\Crontabmng.exe" remove "CustomerName"