Skip to content

Instantly share code, notes, and snippets.

View DavoudTeimouri's full-sized avatar

Teimouri DavoudTeimouri

View GitHub Profile
@DavoudTeimouri
DavoudTeimouri / Re-Customize Existing Virtual Machine.ps1
Created June 9, 2023 13:21
Re-Customize Existing Virtual Machine
# Replace variables with desired values
Get-OSCustomizationSpec -Name $OSSpec | `
Get-OSCustomizationNicMapping | `
Set-OSCustomizationNicMapping -IpMode:UseStaticIP -IpAddress $IP -SubnetMask $Mask -DefaultGateway $Gateway
Get-VM -Name $VMName| Set-VM -OSCustomizationSpec $OSSpec
@DavoudTeimouri
DavoudTeimouri / Iran Standard Time - No Daylight.reg
Created March 23, 2023 16:11
This Windows registry file will add new time zone (IRST) for Iranian users. You can use it until Microsoft release update.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\IRST]
"Display"="(UTC+03:30) IRST"
"Dlt"="Iran Daylight Time"
"MUI_Display"="IRST"
"MUI_Dlt"="IRST"
"MUI_Std"="IRST"
"Std"="IRST"
"TZI"=hex:2e,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
@DavoudTeimouri
DavoudTeimouri / Time Zone Information.ps1
Created March 23, 2023 15:44
This script will decode TZI value from registry. Replace the bytes in the first line of the script with the TZI value in REG_BINARY format that you want to convert.
$tzi = [byte[]]@(0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
$bias = [System.BitConverter]::ToInt32($tzi, 0)
$standardBias = [System.BitConverter]::ToInt32($tzi, 4)
$daylightBias = [System.BitConverter]::ToInt32($tzi, 8)
$standardStart = [System.DateTime]::FromFileTime([System.BitConverter]::ToInt64($tzi, 12))
$daylightStart = [System.DateTime]::FromFileTime([System.BitConverter]::ToInt64($tzi, 20))
Write-Host "Standard bias from UTC: $bias minutes"
Write-Host "Standard offset from UTC: $standardBias minutes"
Write-Host "Daylight bias from UTC: $daylightBias minutes"
@DavoudTeimouri
DavoudTeimouri / Horizon_View_Connection_Session_Duration.ps1
Last active December 23, 2022 04:27
VMware Horizon View Connection (Session) Duration Report
$SQLServer = 'localhost'
$SQLDBName = 'VDIEvents'
$SQLQuery = "select [EventID],
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE([EventType],'AGENT_',''),'ENDED','DISCONNECT'),'RECONNECTED','CONNECT'),'DISCONNECTED','DISCONNECT'),'CONNECTED','CONNECT') as 'Type',
[Time],
REPLACE(REPLACE (REPLACE([UserDisplayName],'domain.org',''),'\',''),'DOMAIN','') as UserName,
[DesktopDisplayName]
from dbo.user_events_hist
where DATEDIFF(Day,Time,GETDATE()) = 1 and SessionType = 'DESKTOP'
order by [UserName],[Time]"
@DavoudTeimouri
DavoudTeimouri / VeeamBR_IPRule_Linux.sh
Created March 24, 2021 13:47
Veeam Backup & Replication - Re-IP Rule on Linux VM - Example 3
#!/bin/bash
# The script will be worked on RHEL/Fedora/CentOS.
# Set logging options
# Variables.
primary_ip_check="192.168.1.254"
replica_ip_check="192.168.2.254"
primary_net="192.168.1"
replica_net="192.168.2"
keep_alive_file="/etc/keepalived/keepalived.conf"
hosts_file="/etc/hosts"
@DavoudTeimouri
DavoudTeimouri / HPE_G10_Server_BIOS_PowerShell.ps1
Created April 16, 2020 15:49
Configure HPE G10 Server BIOS via PowerShell
$Servers= "iLO IP1","iLO IP2"
$Credential=Get-Credential
ForEach ($Server in $Servers)
{
$BIOSConnection= Connect-HPEBIOS -IP $Server -Credential $Credential -DisableCertificateAuthentication
$iLOConnection= Connect-HPEiLO -IP $Server -Credential $Credential -DisableCertificateAuthentication
Start-Sleep -s 30
#Restore Defaults
Reset-HPEBIOSUserDefault -Connection $BIOSConnection -RestoreDefault
Start-Sleep -s 30
@DavoudTeimouri
DavoudTeimouri / HPEG10_SmartArray_LogicalDrive.ps1
Last active December 26, 2020 09:37
Create Logical Drive on HPE ProLiant G10
$Servers= "iLO IP1","iLO IP2"
$Credential=Get-Credential
ForEach ($Server in $Servers)
{
$SAConnection= Connect-HPESA -IP $Server -Credential $Credential -DisableCertificateAuthentication
$iLOConnection= Connect-HPEiLO -IP $Server -Credential $Credential -DisableCertificateAuthentication
Start-Sleep -s 60
$HostPower= Get-HPEiLoServerPower -Connection $iLOConnection
If ($HostPower.Power -eq "Off")
{
@DavoudTeimouri
DavoudTeimouri / WindowsProfileCleanup_Batch.bat
Created May 31, 2019 11:13
Windows Profile Cleanup Script
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto Win7
FOR /D %%X IN ("C:\Documents and Settings\temptask*") DO RD /S /Q "%%X"
net user /add TempTask 1234!@#$qwer
net localgroup administrators TempTask /add
Copy \\SharedFolder\Auto_Clean.vbs C:\Windows /Y
schtasks /create /S %computername% /RU %computername%\TempTask /RP 1234!@#$qwer /TN "TempTask" /TR C:\Windows\Auto_Clean.vbs /SC Daily /ST 05:00 /f
schtasks /run /TN TempTask
timeout /t 30
schtasks /delete /TN TempTask /F
@DavoudTeimouri
DavoudTeimouri / WindowsProfileCleanup_VBScript.vbs
Created May 31, 2019 11:10
Windows Profile Cleanup Script
force_cscript
dim objWSH, sProfile, objFolder
dim objFSO, sProfileRoot, objProfileFolder
dim sTemp, sWindows
set objFSO=CreateObject("Scripting.FileSystemObject")
' Get user profile root folder
set objWSH = CreateObject("WScript.Shell")
@DavoudTeimouri
DavoudTeimouri / AddDomainUser_AdminGroup_VBScript.vbs
Created May 31, 2019 10:57
Add domain user to administrators group on remote machine
'Version 1.0
'Written by Davoud Teimouri
Option Explicit
On Error Resume Next
Dim strComputer
Dim strUser
Dim objGroup
Dim ObjUser
strComputer = Inputbox ("Please enter the computer name (Without domain name):")
strUser= Inputbox ("Please enter the user name:")