Skip to content

Instantly share code, notes, and snippets.

View asvignesh's full-sized avatar

Vignesh A Sathiyanantham asvignesh

View GitHub Profile
@asvignesh
asvignesh / disableuac.ps1
Created April 20, 2019 10:00
Disable UAC on Windows using powershell
$nodes = @("nim-win1-4.asvigneshad.local","nim-win2-5.asvigneshad.local","nim-win3-3.asvigneshad.local","nim-win4-1.asvigneshad.local","nim-win5-5.asvigneshad.local")
$username = "asvigneshad\administrator"
$password = "Password"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
For ($i=0; $i -lt $nodes.Length; $i++) {
$sess = New-PSSession -Credential $cred -ComputerName $nodes[$i]
Enter-PSSession $sess
Set-Itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\policies\system' -Name 'EnableLUA' -value 0
@asvignesh
asvignesh / BackupAllDatabases.ps1
Created May 2, 2019 07:44
Powershell script to backup all database
param(
$serverName,
$backupDirectory
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null
@asvignesh
asvignesh / BackupAllDatabases.ps1
Created May 2, 2019 07:44
Powershell script to backup all database
param(
$serverName,
$backupDirectory
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null
@asvignesh
asvignesh / BackupAllDatabases.ps1
Created May 2, 2019 07:44
Powershell script to backup all database
param(
$serverName,
$backupDirectory
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null
@asvignesh
asvignesh / BackupAllDatabases.ps1
Last active May 2, 2019 07:44
Powershell script to backup all database, to run .\BackupAllDatabases.ps1 -serverName NW\CLUST -backupDirectory c:\backupdir
param(
$serverName,
$backupDirectory
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null
@asvignesh
asvignesh / change_recovery_model_full.ps1
Created May 9, 2019 07:39
Powershell Script to change the recovery model of the databases to FULL
$dbs = Get-SqlDatabase -ServerInstance NW1\CLUST2
foreach ($database in $dbs | where { $_.IsSystemObject -eq $False })
{
$dbName = $database.Name
$sql = @"
USE [master]
GO
ALTER DATABASE [$dbName] SET RECOVERY FULL WITH NO_WAIT
GO
"@
Connect-VIServer -Server vcenter.asvignesh.in -Credential
$ovfPath = "C:\Users\asvig\Downloads\nimesa.ova"
$ovfConfig = Get-OvfConfiguration -Ovf $ovfPath
$ovfConfig.Common.ip.Value="10.10.x.x"
$ovfConfig.Common.netmask.Value="255.255.0.0"
$ovfConfig.Common.gateway.Value="10.0.0.1"
$ovfConfig.Common.dns1.Value="8.8.4.4"
$ovfConfig.Common.dns2.Value="8.8.8.8"
$ovfConfig.NetworkMapping.VM_Network.Value="VM Network"
@asvignesh
asvignesh / vm_from_template.yml
Created June 5, 2019 07:42
Provision vSphere VM from Template on Ansible
- hosts: localhost
connection: local
tasks:
- name: Clone VM from Template
- vmware_guest:
hostname: vcenter.asvignesh.in
username: administrator@asvignesh.in
password: password
validate_certs: no
name: newvm001
@asvignesh
asvignesh / CustomAuthentication.java
Created August 13, 2019 05:19
Spring boot REST Security
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
/**
@asvignesh
asvignesh / Nimesa Role.json
Created August 21, 2019 17:00
Nimesa IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:CopySnapshot",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:ModifyVolumeAttribute",