Skip to content

Instantly share code, notes, and snippets.

View cuongitl's full-sized avatar

Cuongitl cuongitl

View GitHub Profile
@cuongitl
cuongitl / docker_install.sh
Last active May 11, 2025 13:02
Shell Script to auto install Docker on Linux.
#!/bin/bash
:: Filename: docker_install.sh
:: Modified: 2025-05-02
:: Purpose: Quick install Docker on RHEL system.
# Built with ❤️ by Cuongitl (https://infra.lecuong.info)
# Reset color
RESET='\033[0m'
# Colors
@cuongitl
cuongitl / get_current_datetime.bat
Created April 2, 2025 02:05
get the current date and time in the format YYYY-MM-DD HH:MM:SS
:: Batch Script to Get YYYY-MM-DD HH:MM:SS DateTime:
@echo off
:: Get current date and time using wmic
for /f "tokens=2 delims==" %%I in ('"wmic os get localdatetime /value"') do set datetime=%%I
:: Format the datetime as YYYY-MM-DD HH:MM:SS
set year=%datetime:~0,4%
set month=%datetime:~4,2%
set day=%datetime:~6,2%
@cuongitl
cuongitl / dns_change.bat
Created March 15, 2025 08:21
Batch Script to Change/Remove DNS Servers
:: Filename: install-vnstat.sh
:: Modified: 2025-01-02
:: Purpose: Quick remove/set DNS servers for a network card.
:: Built with ❤️ by Cuongitl (https://t.me/Cuongitl)
@echo off
SET NETWORK_CARD=Ethernet
echo Network interface modification script
echo Current interface: %NETWORK_CARD%
@cuongitl
cuongitl / migrate-vm.py
Created January 7, 2025 03:40
Moving a virtual machine between ESXi hosts
# Built with ❤️ by Cuongitl (LE VAN CUONG)
# Filename: migrate-vm.py
# Modified: 2025-01-02
# Purpose: Moving a virtual machine between ESXi hosts
# Reference:
# - https://t.me/Cuongitl
# =============================================================================
import time
from pyVmomi import vim
from pyVim.connect import SmartConnect, Disconnect
@cuongitl
cuongitl / get_vbr_repos_to_json_v2.ps1
Created November 27, 2024 08:47
Powershell: getVeeam Backup & Replication's Repository Information
# Veeam: Powershell get Backup Repository Information: Returns a list of backup repositories.
# version 02
# Define the function
function Get-VBRBackupRepositoryDetails {
$Repos = Get-VBRBackupRepository
$RepoDetails = foreach ($repo in $Repos) {
[PSCustomObject]@{
'Name' = $repo.Name
'ID' = $repo.ID
@cuongitl
cuongitl / get_vbr_repos_to_json.ps1
Created November 27, 2024 03:20
Veeam: Powershell get Backup Repository Information: Returns a list of backup repositories.
# Veeam: Powershell get Backup Repository Information: Returns a list of backup repositories.
# Get-VBRBackupRepository | Format-List *
#Get-VBRBackupRepository |
# Select-Object Name, Id, Type, @{Name="Path";Expression={$_.Path.ToString()}}, Description |
# ConvertTo-Json -Depth 3
Get-VBRBackupRepository |
Select-Object Name,
Id,
@{Name="Type"; Expression={
@cuongitl
cuongitl / install-vnstat.sh
Created November 11, 2024 04:18
Shell Script to auto install vnStat on Linux
#!/bin/bash
# Built with ❤️ by Cuongitl (LE VAN CUONG)
# Telegram: https://t.me/Cuongitl
# Filename: install-vnstat.sh
# Modified: 2024-11-11
# Purpose: Install vnStat - a network traffic monitor for Linux
# Exit the script if any command fails
set -o errexit
# Define the version of vnStat here
@cuongitl
cuongitl / Get-ADGroupbyUser.ps1
Created November 8, 2024 07:03
How to get all groups that a user is a member of?
# Set the username for which to fetch the groups
# Usage: Get-memberOf-User.ps1 <username>
param (
[string]$username
)
# If no username is provided, prompt the user for input
if (-not $username) {
Write-Host "Please provide a username as an argument."
exit
@cuongitl
cuongitl / mariadb_install.sh
Created October 27, 2024 07:12
Shell Script to install MariaDB on Linux
#!/usr/bin/env bash
# exit on error
set -o errexit
params_file='params.ini'
#Including .ini file
. $params_file
if [ ! -f $params_file ]; then
@cuongitl
cuongitl / python-dynamically-choose-the-database-and-table-based-on-input-with-SQLAlchemy.py
Created August 28, 2024 14:30
python-dynamically-choose-the-database-and-table-based-on-input-with-SQLAlchemy
"""
** SQLAlchemy with dynamically input:
- table
- db_url
This is creating a factory function to dynamically choose the database URL and table based on input,
dynamically creating the engine and session based on the input,
then dynamically loading the appropriate model.
** Install packages:
pip install sqlalchemy pymysql