Posts

Showing posts from April, 2019

VMware Esxi rolling reboot after move the host maintenance mode

VMware Esxi rolling reboot after move the host maintenance mode if ($args.count -ne 2) { Write-Host "Usage: rolling_reboot.ps1 <vcenter-nte1.mint> <Host.txt>" exit } # Set vCenter and Cluster name from Arg $vCenterServer = $args[0] $VIHosts = $args[1] # Connect to vCenter Connect-VIServer -Server $vCenterServer  -WarningAction Ignore # Get VMware Server Object based on name passed as arg $ESXiServers = Get-Content $VIHosts | %{ Get-VMhost $_ } # Reboot ESXi Server Function Function RebootESXiServer ($CurrentServer) { # Get VI-Server name $ServerName = $CurrentServer.Name # Put server in maintenance mode Write-Host "** Rebooting $ServerName **" Write-Host "Entering Maintenance Mode" Set-VMhost $CurrentServer -State maintenance -Evacuate | Out-Null # Reboot host Write-Host "Rebooting" Restart-VMHost $CurrentServer -confirm:$false | Out-Null #remove the host Write-Host "removing the host" Remove...

vCheck script password centralized location

vCheck script password centralized location $Username = "domain.com\username"   $password = Get-content \\10.10.0.28\e$\vcheck\chandru\encrypted.txt |ConvertTo-Securestring   $Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$password     $VIConnection = Connect-VIServer $VIServer -Credential $Cred –Protocol Https

Get the Windows 10 Key from Powershell and VB script

Get the Windows 10 Key from Powershell and VB script Get the windows key from Powershell PS C:\WINDOWS\system32> (Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey xxxxx-xxxxx-xxxxx-xxxxx-xxxxx -================================= Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")) Function ConvertToKey(Key) Const KeyOffset = 52 i = 28 Chars = "BCDFG-HJKMP-QRTVW-XY234-6789" Do Cur = 0 x = 14 Do Cur = Cur * 256 Cur = Key(x + KeyOffset) + Cur Key(x + KeyOffset) = (Cur \ 24) And 255 Cur = Cur Mod 24 x = x -1 Loop While x >= 0 i = i -1 KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput If (((29 - i) Mod 6) = 0) And (i <> -1) Then i = i -1 KeyOutput = "-" & KeyOutput End If Loop While i >= 0 ConvertToKey = KeyOutput End Function

Powershell Credential centralized location

Image
Create the encrypted password Using Powershell and call same from location  Read-Host -AsSecureString |ConvertFrom-SecureString |out-file c:\data\password.txt Call the password  Using variable: $Username = "domain.com\username" $password = Get-content \\10.10.0.28\e$\vcheck\chandru\encrypted.txt |ConvertTo-Securestring $Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$password Connect-VIServer ( Get-Content .\vc.txt ) -Credential $Cred –Protocol Https -WarningAction Ignore Connect-VIServer pdvcenter.pd.local -User domain\xxxx-Password xxxxx -WarningAction Ignore Following cmd will send the mail automatically if the script is executed, Send-MailMessage -To Chandru@gmail.com -From admin@localexchage.com -Subject "Any subject" -Body "Message content"  -Credential $cred  -SMTPServer  $smtpserver