Skip to content

Instantly share code, notes, and snippets.

View joeypiccola's full-sized avatar
⛰️

Joey Piccola joeypiccola

⛰️
View GitHub Profile
# search system for KB3125574 and remove\reboot it if it exists
$lesigh = Get-WmiObject -Class Win32_QuickFixEngineering | ?{$_.hotfixid -eq 'KB3125574'}
if ($lesigh)
{
$rmString = "cmd.exe /c wusa.exe /uninstall /KB:3125574 /quiet /norestart"
([WMICLASS]"\\$env:computername\ROOT\CIMV2:win32_process").Create($rmString) | out-null
sleep -Seconds 600
Restart-Computer -Force
}
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering",,48)
For Each objItem in colItems
If objItem.HotfixID = "KB3125574" then
Wscript.Echo "true"
$url = 'https://download.microsoft.com/download/2/C/6/2C6E1B4A-EBE5-48A6-B225-2D2058A9CEFB/Win8.1AndW2K12R2-KB3134758-x64.msu'
$file = Split-Path $url -Leaf
$path = "C:\Windows\Temp\$file"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url,$path)
Invoke-Expression -Command "wusa.exe $path /quiet /norestart"
sleep -seconds 180
@joeypiccola
joeypiccola / Get-Clusters.ps1
Created October 18, 2016 21:57
Get all active windows clusters in your domain
Get-Cluster -Domain mydomain.com | %{Get-ADComputer -properties passwordlastset $_.name | ?{$_.enabled -eq $true} | select Name, PasswordLastSet, Enabled, @{Name="Nodes";Expression={(Get-ClusterNode -Cluster $_.name) -join ', '}}, @{Name="ClusterIP";Expression={(Resolve-DnsName $_.name).ipaddress}}} | ft -a
@joeypiccola
joeypiccola / New-VMDeploy.ps1
Last active January 25, 2024 01:40
sample powershell function with multiple dynamic parameters
Function New-VMDeploy {
[CmdletBinding()]
Param()
DynamicParam {
# Set the dynamic parameters' name
$ParamName_portgroup = 'PortGroup'
Get-WmiObject Win32_logicaldisk -ComputerName LocalHost | Format-Table DeviceID, MediaType, @{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f($_.size/1gb))}}, @{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f($_.freespace/1gb))}}, @{Name="Free (%)";Expression={"{0,6:P0}" -f(($_.freespace/1gb) / ($_.size/1gb))}} -AutoSize
@joeypiccola
joeypiccola / diskpart.bat
Created February 2, 2017 18:29
Use diskpart to online, initialize, and format disks
diskpart
select disk 1
attributes disk clear readonly
online disk
select disk 1
clean
convert gpt
create partition primary
format quick fs=ntfs label="data" unit=64k
assign letter=“E"
@joeypiccola
joeypiccola / WindowsCredentialVault.psm1
Created February 8, 2017 21:43 — forked from guitarrapc/WindowsCredentialVault.psm1
PowerShell Windows Credential Vault Module
function InitializeWindowsCredential
{
Write-Verbose ("Loading PasswordVault Class.")
[void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
}
InitializeWindowsCredential
function ConvertTo-PasswordCredential
{
@joeypiccola
joeypiccola / webscript.bat
Created February 8, 2017 23:45
Ever wanted to run a parameterized batch file that calls a PowerShell script from the web?
REM Usage 'webscript.bat SomeScriptName'
echo off
set script=%1
shift
set scriptname=%script%.ps1
powershell -command "iwr https://artifactory..com/artifactory/scripts/vmwarerunonce/%scriptname% -UseBasicParsing | iex"
function Get-ClusterDatastoreClusters
{
param
(
[CmdletBinding()]
[Parameter(Mandatory)]
[string]$Cluster
)
begin