Skip to content

Instantly share code, notes, and snippets.

@kerard
kerard / extend-vmfs.ps1
Last active June 3, 2019 17:12
Extend-VMFS-PowerCLI
get-cluster | Get-VMHost | Get-VMHostStorage -RescanAllHba -rescanvmfs
$datastore = get-datastore "DATASTORE-NAME"
$esxi = get-view -id ($datastore.ExtensionData.Host | select-object -last 1 | select -ExpandProperty Key)
$datastoresystem = get-view -id $esxi.ConfigManager.DatastoreSystem
$expandOptions = $datastoreSystem.QueryVmfsDatastoreExpandOptions($datastore.ExtensionData.MoRef)
$datastoreSystem.ExpandVmfsDatastore($datastore.ExtensionData.MoRef,$expandOptions.spec)
@kerard
kerard / p2v-to-pvs.cmd
Last active April 24, 2019 18:02
Recover P2V PVS Target from Repair Media
REM Convert guest VM from EFI to BIOS boot, grow disk, etc. before doing this
REM Boot to appropriate Windows Server install media and open repair command prompt
diskpart
select disk 0
list partition
select partition 1
assign
select partition 2
assign
list volume
@kerard
kerard / export-creds.ps1
Created April 18, 2019 19:26
Save Credentials to XML
get-credential | export-clixml -path "C:\foo\bar\credential.xml"
@kerard
kerard / hol-iis.ps1
Last active February 19, 2019 17:30
HOL
install-windowsfeature -name web-server -includemanagementtools
remove-item c:\inetpub\wwwroot\iisstart.htm
add-content -path "C:\inetpub\wwwroot\iisstart.htm" -value $("Hello World from $($env:computername)")
@kerard
kerard / enable-ldaplogging.cmd
Created February 14, 2019 18:56
Enable LDAP Bind Logging on Domain Controller
Reg Add HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics /v "16 LDAP Interface Events" /t REG_DWORD /d 2
@kerard
kerard / users-noEMS.ps1
Last active February 5, 2019 19:16
Users without EMS SKU in Office 365
Connect-MsolService -Credential (Get-Credential)
$licensedMSOLUsers = Get-MsolUser -MaxResults 5000 | ? {$_.islicensed -eq $true}
($licensedMSOLUsers) | ? {$_.licenses.accountskuid -notcontains "office365tenant:EMS"}
@kerard
kerard / get-vbrprotectiongroupmembers.ps1
Created February 4, 2019 15:23
Get VBR Protection Group Members
(Get-VBRProtectionGroup -name "Protection Group Name").container.entity | % {$_.name}
@kerard
kerard / enable-ssh.ps1
Created January 14, 2019 19:19
Enable SSH on Hosts in vSphere Cluster
get-cluster 'clustername' | Get-VMHost | Foreach {Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}
@kerard
kerard / convert-pfx.sh
Created December 31, 2018 17:39
Convert Windows PFX Export to Split Cert and Key
# useful for systems that don't want a whole PEM file
openssl pkcs12 -in windows-pfx-export.pfx -out exported-pem.pem -nodes
openssl rsa -in exported-pem.pem -out private.key
openssl x509 -outform pem -in exported-pem.pem -out certificate.cer
@kerard
kerard / set-nsservicegroupciphers.sh
Created December 31, 2018 14:32
Set Netscaler Back-End Cipher Suites
bind ssl serviceGroup ServiceGroup_Name -cipherName CipherGroup_BestPractices
unbind ssl serviceGroup ServiceGroup_Name -cipherName DEFAULT_BACKEND