Skip to content

Instantly share code, notes, and snippets.

View brianfgonzalez's full-sized avatar

Brian Gonzalez brianfgonzalez

View GitHub Profile
# Lock After Password Change System Scheduled Task System
# Jacob Regruit
# 08/12/2021
Start-Transcript c:\windows\temp\LockOnPasswordChangeSystem.log -Append
# Set Paths
$LockAfterPasswordChangePath = 'C:\ProgramData\adatum\LockOnPasswordChange'
$PreToastPath = 'C:\ProgramData\adatum\LockOnPasswordChange\New-ToastNotification.ps1'
$VBSToastPath = 'C:\ProgramData\adatum\LockOnPasswordChange\InstallToastHidden.vbs'
@brianfgonzalez
brianfgonzalez / wipeSccmClient.ps1
Created January 25, 2024 15:54
wipe sccm client
<#
.NOTES
===========================================================================
Created on: Feb/12/2020
Updated on: Sep/09/2020
Version : 1.0, Initial Release
1.1, Updated with timer function
Created by: Vinicio Oses
Organization: System Center Configuration Manager Costa Rica
Filename: Wipe-ConfigMgrAgent.ps1
@brianfgonzalez
brianfgonzalez / getIpSubnet.ps1
Last active January 16, 2024 19:43
getIpSubnet.ps1 ca
# functions were pulled from
# https://www.itprotoday.com/powershell/working-ipv4-addresses-powershell
function ConvertTo-IPv4MaskString {
<#
.SYNOPSIS
Converts a number of bits (0-32) to an IPv4 network mask string (e.g., "255.255.255.0").
.DESCRIPTION
Converts a number of bits (0-32) to an IPv4 network mask string (e.g., "255.255.255.0").
@brianfgonzalez
brianfgonzalez / updateDeviceVars.ps1
Created December 20, 2023 18:48
updateDeviceVars.ps1
$MachineSettingsClass = Get-WmiObject -ns "root\sms\site_ps1" -Query "SELECT ResourceID FROM SMS_MachineSettings WHERE ResourceID = '16777220'"
if ($MachineSettingsClass)
{
Write-Host 'initial check of vars'
$MachineSettingsClass.get() | Out-Null
$MachineSettingsClass.machinevariables
Write-Host 'now clearing vars'
$MachineSettingsClass.MachineVariables = @()
@brianfgonzalez
brianfgonzalez / scpEndpointPortConnectionTest.ps1
Created September 19, 2023 17:21
test port connectivity to Microsoft Endpoints using powershell. Run on Service Connection Point.
$endpoint ='aka.ms','manage.microsoft.com','dc.visualstudio.com','graph.windows.net',
'go.microsoft.com','management.azure.com','login.microsoftonline.com','aadcdn.msauth.net',
'aadcdn.msftauth.net','configmgrbits.azureedge.net','login.live.com','login.windows.net',
'account.live.com','clientconfig.passport.net','gateway.configmgr.manage.microsoft.com'
foreach ($i in $endpoint) {
$Result = (Test-NetConnection $i -Port 443).TcpTestSucceeded
if ($Result -eq $True) {
Write-Host "Connection to $i ...... Succeeded." -ForegroundColor Green
} else {
Write-Host "Connection to $i .......... failed." -ForegroundColor Red }
@brianfgonzalez
brianfgonzalez / repairPkgInContentLib.ps1
Last active September 15, 2023 18:50
attempts to repair a pkg in contentlib using pkg files from working/VALID content lib.
$workingContentLib = '\\bg--ps1site\SCCMContentLib$'
$nonWorkingContentLib = '\\bg--ps1dpmp2.bg-lab.com\SCCMContentLib$'
$packageId = 'CS100004'
$strings = [System.Collections.Generic.HashSet[string]]::new()
get-childitem ('{0}\datalib\{1}*' -f $workingContentLib, $packageId) -Filter "*.ini" |
Get-Content |
ForEach-Object {
$_ -Match 'Hash=(.{4})' | Out-Null
@brianfgonzalez
brianfgonzalez / office2016-example-configuration.xml
Created August 8, 2023 06:17
office2016-example-configuration.xml
<!-- Office-ProPlus-Updates/Setup-SCCMOfficeUpdates/configuration_template.xml -->
<Configuration>
<!-- SOURCE DOCUMENTATION: https://technet.microsoft.com/en-us/library/jj219426 -->
<!-- <Add SourcePath="\\Server\Share\" Version="15.1.2.3" OfficeClientEdition="32" >
<Product ID="O365ProPlusRetail" PIDKEY="12345-12345-12345-12345-12345">
<Language ID="en-us" />
<Language ID="es-es" />
<ExcludeApp ID="Access" />
@brianfgonzalez
brianfgonzalez / wsus_troubleshooting.ps1
Last active January 18, 2024 20:10
troubleshooting wsus clients with powershell via step-by-step commands
#Troubleshoot Win Updates
# ISE tip -- F8 = run highlighted text
# changelog:
# 20231023 - added capi2 eventvwr enable and pshell script to view iis logs.
# 20231026 - added more filtering options to iis log script and support to output to csv.
# 20231110 - added script to read through capi2 event logs with a searchstring.
# 20240118 - added utc->localTime to IIS results
# 1\ enable ccm verbose
# Version 1.1 - BFG
# cmdline: powershell.exe -ExecutionPolicy Bypass -File zWinUpdateLocalCleanup.ps1
$transcriptLogFilePath = "C:\Windows\CCM\Logs\zWinUpdateLocalCleanup.log"
Start-Transcript -Path $transcriptLogFilePath -Force
Write-Host "Starting script execution..."
Write-Host "Running sfc /scannow"
#Start-Process -FilePath $env:windir\system32\sfc.exe -ArgumentList '/scannow' -Wait -Verbose
<?xml version="1.0" encoding="utf-16"?>
<DesiredConfigurationDigest xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/07/10/DesiredConfiguration">
<!--Authored against the following schema version: 5-->
<ConfigurationPolicy AuthoringScopeId="ScopeId_7DA39272-F456-41A7-9E87-14EFC4F3D726"
LogicalName="ConfigurationPolicy_01287168-7a17-494d-8009-f7cd24dd9c60"
Version="5"
ConfigurationFlags="8">
<Annotation xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules">
<DisplayName Text="Bitlocker Policy Test"
ResourceId="ID-fcaeb424-bd4b-4e73-b309-59276f42eeb0"/>