This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($VMhost in (Get-VMHost)) | |
{ | |
#Stop SSH Service | |
$ServiceList = Get-VMHostService -VMhost $VMhost | |
$SSHservice = $ServiceList | Where-Object {$_.Key -eq "TSM-SSH"} | |
If ($SSHservice.Running -eq $true) {Stop-VMHostService -HostService $SSHService -Confirm:$false} | |
else {Write-Output "SSH Server on host $VMhost is Stopped"} | |
$Shellservice = $ServiceList | Where-Object {$_.Key -eq "TSM"} | |
If ($Shellservice.Running -eq $true) {Stop-VMHostService -HostService $Shellservice -Confirm:$false} | |
else {Write-Output "Shell Server on host $VMhost is Stopped"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Credential = Get-Credential | |
$Password = $Credential.GetNetworkCredential().Password | |
if(($Password -cmatch '[a-z]') -and ($Password -cmatch '[A-Z]') -and ($Password -match '\d') -and ($Password.length -ge 12) -and $Password -match '!|@|#|%|^|&|$|_') { | |
Remove-Variable Password | |
Write-Output "Password is valid" | |
} | |
else { | |
Remove-Variable Password | |
$Valid = $false | |
Throw "Invalid Password! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start-Transcript -Path "C:\Scripts\Logs\Backup-$((Get-Date).ToString('yyyy-MM-dd-hh-mm')).log" | |
#region: Log Rotate | |
$LogPath = "C:\Scripts\Logs\*" | |
$LogFiles = "*.log" | |
[int] $LogRetention = "-14" # in Days | |
Get-ChildItem $LogPath -Include $LogFiles -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays($LogRetention)} | Remove-Item | |
#endregion | |
#region: Import Module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function GetArrayDupes { | |
param($array) | |
$hash = @{} | |
$array | %{ $hash[$_] = $hash[$_] + 1 } | |
$result = $hash.GetEnumerator() | ?{$_.value -gt 1} | %{$_.key} | |
Return $result | |
} | |
$VMs = Get-VM | |
$IPs = $VMs.Guest.IPAddress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CiDs = Get-CIDatastore | where {$_.Name -like "LOCAL-*"} | Get-CIView | |
foreach ($object in $CiDs ){ | |
$Cap = $object.TotalCapacityGb | |
$red = [math]::round($object.TotalCapacityGb/85, 0) | |
$yellow = [math]::round($object.TotalCapacityGb/75, 0) | |
Write-Host "Total Cap: '$cap GB'" | |
Write-Host "New ThresholdRedGb: '$red GB'" | |
Write-Host "New ThresholdYellowGb: '$yellow GB'" | |
$object.ThresholdRedGb = $red |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-MyESXiOption { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] | |
[String] $Name, | |
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)] | |
[String] $Value | |
) | |
process { | |
$myESXiOption = Get-AdvancedSetting -Entity $VMhost -Name $Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[String]$ClusterName = "Compute01" | |
[String]$LocalPath = "D:\Image\HPE-20180220.zip" | |
[String]$DepotName = "HPE-20180220.zip" | |
[String]$TempDatastoreName = "LOCAL*" | |
$VMhosts = Get-Cluster -Name $ClusterName | Get-VMHost | Where-Object {$_.ConnectionState -eq "Maintenance"} | |
foreach ($VMhost in $VMhosts) { | |
#region: Upload Patch | |
$Datastore = $VMhost | Get-Datastore -Name $TempDatastoreName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Credits: http://vman.ch/vrops-suite-api-properties-import/ | |
#region: SSL Config for SelfSigned Cert and force TLS 1.2 | |
add-type @" | |
using System.Net; | |
using System.Security.Cryptography.X509Certificates; | |
public class TrustAllCertsPolicy : ICertificatePolicy { | |
public bool CheckValidationResult( | |
ServicePoint srvPoint, X509Certificate certificate, | |
WebRequest request, int certificateProblem) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VMware vRealize Orchestrator action sample | |
// | |
// Removes duplicates from an array, with the option to also sort the array | |
// | |
// For vRO 6.0+ | |
// | |
// Action Inputs: | |
// a - Array/Any - Array with potential duplicates | |
// doSort - boolean - Sort the array also? Potentially better performance than unsorted algorithm | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires PowerShell 5.1 | |
# Requires .Net 4.5.2 and Reboot | |
#region: Variables | |
$source = "X:" | |
$licensefile = "C:\_install\veeam.lic" | |
$username = "svc_veeam" | |
$fulluser = $env:COMPUTERNAME+ "\" + $username | |
$password = "Password!" | |
$CatalogPath = "D:\VbrCatalog" |