Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am vjason1 on github.
  • I am jasonventresco (https://keybase.io/jasonventresco) on keybase.
  • I have a public key whose fingerprint is 392A E596 398A 6CD8 130C B8A5 E559 AE05 7E21 50BC

To claim this, I am signing this object:

$DesktopName = $args[0]
$Machine_Id = (Get-DesktopVM -Name $DesktopName).machine_id
foreach ($Ident in $Machine_id){
Remove-UserOwnership -Machine_id $Ident
}
use [master]
go
CREATE DATABASE [EUC_AppVolumes1] ON PRIMARY
(NAME = N'EUC_AppVolumes1', FILENAME = N'D:\SomeDatabasePathHere\EUC_AppVolumes1.mdf', SIZE = 10MB, FILEGROWTH = 10% )
LOG ON
(NAME = N'EUC_AppVolumes1_log', FILENAME = N'D:\SomeDatabaseLogPathHere\EUC_AppVolumes1.ldf', SIZE = 1000KB, FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
ALTER DATABASE [EUC_AppVolumes1] SET
READ_COMMITTED_SNAPSHOT ON
USE [master]
GO
CREATE DATABASE [EUC_AppVolumes1]
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
ALTER DATABASE [EUC_AppVolumes1] MODIFY FILE
( NAME = N'EUC_AppVolumes1' , SIZE = 10MB, FILEGROWTH = 10% )
GO
ALTER DATABASE [EUC_AppVolumes1] MODIFY FILE
( NAME = N'EUC_AppVolumes1_log' , SIZE = 1000KB, FILEGROWTH = 10% )
USE [master]
GO
CREATE DATABASE [EUC_AppVolumes1]
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
ALTER DATABASE [EUC_AppVolumes1] MODIFY FILE
( NAME = N'EUC_AppVolumes1' , SIZE = 10MB, FILEGROWTH = 10% )
GO
ALTER DATABASE [EUC_AppVolumes1] MODIFY FILE
( NAME = N'EUC_AppVolumes1_log' , SIZE = 1000KB, FILEGROWTH = 10% )
$clusterName= Read-Host 'Please enter the target vSphere cluster name to update the Disk.SchedNumReqOutstanding value for all XtremIO datastores'
$vmhosts = get-vmhost –location $clusterName
Get-VMHost -Location $clusterName | Get-ScsiLun -LunType "disk"| where {$_.vendor -eq "XtremIO"}| where {$_.MultipathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin
foreach ($vmhost in $vmhosts) {
$esxcli = get-esxcli -vmhost $vmhost
$AllLUNs = get-scsilun -vmhost $vmhost | where {$_.vendor -eq "XtremIO"}
foreach ($lun in $AllLUNs) {
$CN = $lun.canonicalname
$EsxCli.storage.core.device.set($null, $cn, $null, $null, $null, $null, $null, 256, $on)
}
$clusterName= Read-Host 'Please enter the target vSphere cluster name to update the Disk.SchedNumReqOutstanding value and set Round Robin load balancing for all XtremIO datastores'
$vmhosts = get-vmhost –location $clusterName
Get-VMHost -Location $clusterName | Get-ScsiLun -LunType "disk"| where {$_.vendor -eq "XtremIO"}| where {$_.MultipathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin
foreach ($vmhost in $vmhosts) {
$esxcli = get-esxcli -vmhost $vmhost
$AllLUNs = get-scsilun -vmhost $vmhost | where {$_.vendor -eq "XtremIO"}
foreach ($lun in $AllLUNs) {
$CN = $lun.canonicalname
$EsxCli.storage.core.device.set($null, $null, $cn, $null, $null, $null, $null, $null, $null, $null, $null, 256, $on, $null)
}
$clusterName= Read-Host 'Please enter the target vSphere cluster name to create the XtremIO NMP rules and optimize other settings'
$vmhosts = get-vmhost –location $clusterName
foreach ($vmhost in $vmhosts) {
Set-VMhostAdvancedConfiguration -vmhost $vmhost Disk.SchedQuantum -Value 64
Set-VMhostAdvancedConfiguration -vmhost $vmhost Disk.DiskMaxIOSize -Value 4096
Get-AdvancedSetting -entity $vmhost -Name DataMover.MaxHWTransferSize | Set-AdvancedSetting -Value 256 -Confirm:$false
$esxcli = get-esxcli -vmhost $vmhost
$esxcli.storage.nmp.satp.rule.add($null, "tpgs_off", "XtremIO-ActiveActive", $null, $null, $null, "XtremApp", $null, "VMW_PSP_RR", "iops=1", "VMW_SATP_DEFAULT_AA", $null, "vendor", "XtremIO")
}
Echo 'This script should be run again whenever additional ESXi servers are added to the cluster.'
cls
Echo 'Expect to see errors if the ESXi hosts currently have different root passwords. Simply repeat the script until all current root passwords have been supplied (and subsequently updated).'
Echo ''
$vsphere= Read-Host 'Please enter the vCenter Server that manages the ESXi hosts whose root password you wish to update'
$root_passwd= Read-Host 'Please enter the current ESXi root password. If multiple passwords are currently in use, repeat the script and supply each in turn'
$new_root_passwd= Read-Host 'Please enter the new ESXi root password'
Echo ''
# $vsphere = "vdi-vc-02" - Optional if hard coding vcenter
$root_user = "root"
CLS
Echo ''
Echo 'Please note this script is hard coded to create new accounts with ESXi root permissions and shell access.'
Echo ''
Echo 'If an account with the specified user name already exists the password will be updated, and the account granted root permissions and shell access.'
Echo ''
$vsphere= Read-Host 'Please enter the vCenter Server name that manages the ESXi hosts where you wish to create the new account'
$root_passwd= Read-Host 'Please enter the current ESXi root password.'
$new_user= Read-Host 'Please enter a name of the new or existing user account'