Skip to content

Instantly share code, notes, and snippets.

View joeypiccola's full-sized avatar
⛰️

Joey Piccola joeypiccola

⛰️
View GitHub Profile
@joeypiccola
joeypiccola / x.ps1
Last active May 3, 2017 02:38
code post for ps org pester forum post (Test-InvokeVMScript - 0)
# my function
Function Test-InvokeVMScript
{
<#
[removed]
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
@joeypiccola
joeypiccola / log.ps1
Created May 3, 2017 16:15
simple logger
[CmdletBinding()]
param()
function Start-DAVLog
{
[cmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$logFile
,
@joeypiccola
joeypiccola / x.ps1
Last active May 3, 2017 19:42
code snippit for ps org
foreach ($vCenter in $vCenters) {
foreach ($template in $templates) {
# try to convert the current template to a VM
try {
Write-Verbose "Trying to convert template $($template.name) to a VM."
Set-Template -Template $template -ToVM -ErrorAction Stop
Write-Verbose "Successfully converted template $($template.name) to a VM."
}
catch {
Write-Verbose "Failed to convert template $($template.name) to a VM with the following exception."
@joeypiccola
joeypiccola / Install-WinUpdates.ps1
Created July 26, 2017 05:12
A script to install Windows Updates in batches leveraging the PSWindowsUpdate PowerShell module.
# script used to incremenelty install windows udpates
# expects the PSWindowsUpdate module to be installed
# needs to be run by a packer powershell provisioner at least 4 times in a row with reboots in between (4x depends on your OS)
# no longer used since https://github.com/rgl/packer-provisioner-windows-update came to be with https://github.com/rgl/packer-provisioner-windows-update/pull/4
$UpdateLimit = 50
$updates = Get-WUList
if ($updates)
{
Write-Host "$($updates.count) total updates found for install." -ForegroundColor Green
[CmdletBinding()]
param()
function Start-Log
{
[cmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$logFile
,
function Get-ClusterDatastoreClusters
{
param
(
[CmdletBinding()]
[Parameter(Mandatory)]
[string]$Cluster
)
begin
function Get-ClusterPortGroups
{
param
(
[CmdletBinding()]
[Parameter(Mandatory)]
[string]$Cluster
)
begin
@joeypiccola
joeypiccola / Validate-IPAddress.ps1
Created November 10, 2017 18:01
simple way to validate an ipv4 address
function Validate-IPAddress
{
param
(
[Parameter()]
[string]$IP
)
if (($ip -as [ipaddress]) -and (($IP.Split('.'))).count -eq 4)
{
Write-Output $true
@joeypiccola
joeypiccola / Test-Unique.ps1
Created November 10, 2017 18:04
Test the uniqueness of an array of strings
function Test-Unique
{
param
(
[Parameter()]
[array]$strings
)
$stringsraw = $strings
# an awful way to check for not null or empty on the pipeline. don't judge
@joeypiccola
joeypiccola / site.pp
Created December 20, 2017 22:38
Example site.pp to dynamically handle Classification node groups
## site.pp ##
# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
# used when an agent connects to a master and asks for an updated configuration.
#
# Global objects like filebuckets and resource defaults should go in this file,
# as should the default node definition. (The default node can be omitted
# if you use the console and don't define any other nodes in site.pp. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.)