Skip to content

Instantly share code, notes, and snippets.

View 9to5IT's full-sized avatar

9to5IT 9to5IT

View GitHub Profile
@9to5IT
9to5IT / Get-UniqueVCEvents.ps1
Last active August 16, 2021 12:51
PowerShell: Get list of unique vCenter Events
#-----------------------------------------------------------------------------
# Import PowerCLI Module
#-----------------------------------------------------------------------------
Add-PSSnapin VMware.VimAutomation.Core
#-----------------------------------------------------------------------------
# Connect to vCenter Server
#-----------------------------------------------------------------------------
$Server = Read-Host 'Specify the vCenter Server or ESXi Host to connect to (IP or FQDN)?'
Connect-VMwareServer -VMServer $Server
@9to5IT
9to5IT / Get-VCEvents.ps1
Last active August 16, 2021 12:51
PowerShell: Collect vCenter Events
#-----------------------------------------------------------------------------
# Import PowerCLI Module
#-----------------------------------------------------------------------------
Add-PSSnapin VMware.VimAutomation.Core
#-----------------------------------------------------------------------------
# Connect to vCenter Server
#-----------------------------------------------------------------------------
$Server = Read-Host 'Specify the vCenter Server or ESXi Host to connect to (IP or FQDN)?'
Connect-VMwareServer -VMServer $Server
@9to5IT
9to5IT / PS_Script_Template_V2_Logs.ps1
Last active May 1, 2023 17:14
PowerShell: Script Template Version 2 (with logging)
#requires -version 4
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@9to5IT
9to5IT / PS_Script_Template_V2_NoLogs.ps1
Last active January 24, 2023 15:55
PowerShell: Script Template Version 2 (without logging)
#requires -version 4
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@9to5IT
9to5IT / PoweCLI_Script_Template_V2_Logs.ps1
Last active August 21, 2022 14:30
PowerShell: PowerCLI Script Template Version 2 (with logging)
#requires -version 4
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@9to5IT
9to5IT / PowerCLI_Script_Template_V2_NoLogs.ps1
Last active August 21, 2022 14:29
PowerShell: PowerCLI Script Template Version 2 (without logging)
#requires -version 4
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
@9to5IT
9to5IT / Get-RDM.ps1
Last active August 16, 2021 12:50
PowerShell: Searching for RDM disks using PowerCLI
#requires -version 4
<#
.SYNOPSIS
Seaches for an RDM with the specified LUN ID.
.DESCRIPTION
Searches the vCenter environment to find the Virtual Machine that has an RDM configured with a particular LUN ID.
.PARAMETER None
@9to5IT
9to5IT / Set-HostSNMP.ps1
Created June 7, 2016 13:03
PowerShell: Configure SNMP on an ESXi Host
#requires -version 4
<#
.SYNOPSIS
Configure SNMP Settings on ESXi Hosts
.DESCRIPTION
Connect to vCenter Server and configure all ESXi hosts with SNMP settings
.PARAMETER None
@9to5IT
9to5IT / Find-RegistryValues.ps1
Created June 23, 2016 12:06
PowerShell: Enumerate & Search Registry Key values with PowerShell
$RegKey = (Get-ItemProperty 'HKCU:\Volatile Environment')
$RegKey.PSObject.Properties | ForEach-Object {
If($_.Name -like '*View*'){
Write-Host $_.Name ' = ' $_.Value
}
}
@9to5IT
9to5IT / Manage-ADUsers.ps1
Created July 4, 2016 12:04
PowerShell: Cleanup Inactive AD User Accounts
Import-Module ActiveDirectory
# Set the number of days since last logon
$DaysInactive = 90
$InactiveDate = (Get-Date).Adddays(-($DaysInactive))
#-------------------------------
# FIND INACTIVE USERS
#-------------------------------
# Below are four options to find inactive users. Select the one that is most appropriate for your requirements: