Skip to content

Instantly share code, notes, and snippets.

{
"autoStart": true,
"fullscreen": true,
"lazyLoadTabs": false,
"websites": [
{
"url": "http://kwiki.kastle.com/display/AnonView/System+Status?frameable=true",
"duration": 20,
"tabReloadIntervalSeconds": 60
},
@TScalzott
TScalzott / Send-vSphereAlarms.ps1
Created September 1, 2019 15:11
Post active vSphere alarms to a Microsoft Teams channel
<#
.SYNOPSIS
Post active vSphere alarms to a Microsoft Teams channel.
.DESCRIPTION
Connect to the specified vSphere vCenter, query for all active alarms, and post those
as a card to Microsoft Teams via a Webhook.
The card will contain one section per alarm with a few facts: the cluster involved,
the date and time of the alarm, the alarm status (yellow/red/etc), and whether
@TScalzott
TScalzott / PingLog.ps1
Created August 15, 2019 12:53
Log timestamped ping replies and timeouts to the screen and a logfile
<#
.DESCRIPTION
Log timestamped ping replies and timeouts to the screen and a logfile
.PARAMETER host
The host or IP to ping
.EXAMPLE
PingLog.ps1 www.google.com
@TScalzott
TScalzott / Remove-StaleProfiles.ps1
Created August 1, 2019 14:54
Remove stale user profiles from a system, remote or local
#Requires -Version 3
<#
.SYNOPSIS
Remove stale user profiles, based on last used date
.PARAMETER NumDays
Number of days stale. Anything older than this will be removed
.PARAMETER computerName
@TScalzott
TScalzott / Clean-Cache.ps1
Created August 1, 2019 14:52
Clean IE and Chrome cache for all stale users. Handy on RDS servers.
<#
.SYNOPSIS
Clean old cached items.
.DESCRIPTION
Forcibly clear Google Chrome and IE Cache for all users staler than a certain number of days
.PARAMETER Days
The number of days stale. Determined by LastUsed time from the user's profile.
@TScalzott
TScalzott / Add-RSAT.ps1
Created August 1, 2019 14:50
Use DISM to add any missing RSAT tools.
<#
Install all missing Remote Server Administration Tools.
Windows 10 Feature Updates are reliably removing RSAT features. This script adds them back.
#>
$Caps = Dism.exe /ONLINE /GET-CAPABILITIES
$Caps | Select-String -Pattern ' : (Rsat\..*)' -Context 0, 1 |
ForEach-Object {
if ($_.Context.PostContext -match "Not Present") {
if ($_ -match ' : (Rsat\..*)') {
$command = "DISM.EXE /Online /Add-Capability /CapabilityName:$($matches[1])"
@TScalzott
TScalzott / Set-Syslog.ps1
Created January 31, 2019 01:08
Set syslog on all vSphere host
$syslog = 'udp://1.2.3.4:514' # change to your syslog host
$Hosts = Get-VMHost | Sort-Object Name
$Hosts | ForEach-Object {
try {
Write-Output "Setting $_ Syslog to $syslog"
Set-VMHostSysLogServer -VMHost $_ -SysLogServer $syslog -ErrorAction Stop | Out-Null
}
catch [Exception] {
Write-Output " Operation failed."
@TScalzott
TScalzott / Get-VMsnaps.ps1
Created December 27, 2018 14:52
List VM Snapshots
Get-VM |
ForEach-Object {
$Snap = Get-Snapshot -VM $_
if (($Snap | Measure-Object).Count -gt 0) {
Format-Table $_.Name,
@{N = "Num Snaps"; E = {($Snap | Measure-Object).Count}},
@{N = "Total MB"; E = {($Snap | Measure-Object -Sum SizeMB).Sum}},
@{N = "Total GB"; E = {($Snap | Measure-Object -Sum SizeGB).Sum}}
}
}
@TScalzott
TScalzott / Get-ClusterToolsMissing.ps1
Last active December 31, 2018 20:11
Find Cluster VMs Missing VMware Tools
@("Cluster1", "Cluster2") |
ForEach-Object {
Get-Cluster -Name $_ |
Get-VM | Sort-Object Name |
Where-Object { $_.PowerState -eq "PoweredOn" } |
ForEach-Object { Get-View $_.ID } |
Where-Object { $_.Guest.ToolsVersionStatus -eq "guestToolsNotInstalled" } |
Select-Object Name, @{N = "Tools Version"; E = {$_.Config.Tools.ToolsVersion}},
@{ N = "Status"; E = {$_.Guest.ToolsVersionStatus}} |
Format-Table -AutoSize
@TScalzott
TScalzott / Load-UserHives.ps1
Created December 18, 2018 22:48
Load/unload all discovered user hives into the registry
<#
.SYNOPSIS
Load/unload all discovered user hives into the registry
.DESCRIPTION
For the local machine, load all discovered user hives. Provide the option to then come
back and unload those same hives.
Why might you want to do this: