Skip to content

Instantly share code, notes, and snippets.

View brianfgonzalez's full-sized avatar

Brian Gonzalez brianfgonzalez

View GitHub Profile
@brianfgonzalez
brianfgonzalez / Wipe-ConfigMgrAgent.ps1
Created October 4, 2021 14:59
Automate the removal and clean up of Config Mgr agent via PowerShell.
<#
.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 / createRegionalSoftwareCollections.ps1
Last active December 4, 2020 19:59
Iterates through an array of collection Ids and creates regional specific collections for each element.
$collectionIdList = @(
'SIH00021',
'SIH0001D',
'SIH00020',
'SIH00030',
'SIH00024',
'SIH0001F',
'SIH0002C',
'SIH0002B'
)
@brianfgonzalez
brianfgonzalez / ServiceNowToSecRmmSccm.ps1
Last active November 25, 2020 15:34
Sync USB Devices From ServiceNow to SCCM (using secRMM Console Extension)
# ============================================================================
# Module: ServiceNowSecRMMSCCM.ps1
#
# Purpose: Call Polypore.net ServiceNow REST API to get
# secRMM device ids by region.
#
# This powershell script is called by a cmd file named ServiceNowSecRMMSCCM.cmd
# This powershell script and the cmd file named ServiceNowSecRMMSCCM.cmd
# need to be in the same directory
#
$path = "C:\Windows\Temp\Country.xml"
New-item $path -ItemType File -Force -ErrorAction SilentlyContinue
Set-content $path '<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!--UserList-->
<gs:UserList>
<gs:User UserID="Current" CopySettingsToSystemAcct="true" CopySettingsToDefaultUserAcct="true" />
</gs:UserList>
<!--DisplayLanguage-->
<gs:MUILanguagePreferences>
$Inputprofile = "en-gb"
$inputlanguageid = "0809:00000809"
#https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825682(v=win.10)?redirectedfrom=MSDN
$GeoID = "244"
#https://docs.microsoft.com/en-us/windows/win32/intl/table-of-geographical-locations
write-host "Successfully added variables inputprofile=$Inputprofile,inputlanguageid=$InputLanguageID and GeoID=$Geoid"
$path = "C:\Windows\Temp\Country.xml"
@brianfgonzalez
brianfgonzalez / grabRegistryUninstallStrings.ps1
Created February 28, 2020 15:57
Quick snippet to output a grid of all uninstall strings from the registry.
$ColRegUinst = @()
(Get-Item -Path 'HKLM:\software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall').GetSubKeyNames() |
%{
if ( (Get-Item -Path "HKLM:\software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$_").GetValue("DisplayName") -ne $null)
{
$ObjRegUinst = New-Object System.Object
$ObjRegUinst | Add-Member -Type NoteProperty -Name Publisher -Value (Get-Item -Path "HKLM:\software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$_").GetValue("Publisher")
$ObjRegUinst | Add-Member -Type NoteProperty -Name Name -Value (Get-Item -Path "HKLM:\software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$_").GetValue("DisplayName")
$ObjRegUinst | Add-Member -Type NoteProperty -Name Uninstall -Value (Get-Item -Path "HKLM:\software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$_").GetValue("UninstallString")
$ColRegUinst += $ObjRegUinst
@brianfgonzalez
brianfgonzalez / unattend.xml
Created November 27, 2019 22:28
unattend for winpe x64 that calls promptForDiskWipe.bat before calling Litetouch.vbs
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<Display>
<ColorDepth>32</ColorDepth>
<HorizontalResolution>1024</HorizontalResolution>
<RefreshRate>60</RefreshRate>
<VerticalResolution>768</VerticalResolution>
</Display>
@brianfgonzalez
brianfgonzalez / promptForDiskWipe.bat
Last active November 27, 2019 22:19
batch script used to prompt user for cleaning of disk and if yes is specified the disk 0 will be cleaned using diskpart.
echo return = msgbox("Do you want to wipe the drive?", 4, "This is my title") > %temp%\msgbox.vbs
echo if return = 6 then >> %temp%\msgbox.vbs
echo wscript.quit(66) >> %temp%\msgbox.vbs
echo end if >> %temp%\msgbox.vbs
wscript %temp%\msgbox.vbs
if %errorlevel%==66 (
echo select disk 0 > %temp%\diskpart.txt
echo clean >> %temp%\diskpart.txt
diskpart.exe /s %temp%\diskpart.txt
)
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
Function AwaitAction($WinRtAction) {
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
@brianfgonzalez
brianfgonzalez / Unattend.xml
Created May 7, 2019 21:08
x64 Windows PE custom unattend.xml that calls RecoveryWipe.ps1 before calling Litetouch.wsf.
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Description>BG Info</Description>
<Order>1</Order>
<Path>powershell.exe -executionpolicy bypass -file x:\RecoveryWipe.ps1</Path>
</RunSynchronousCommand>