Skip to content

Instantly share code, notes, and snippets.

@pvanderwoude
pvanderwoude / Remediate-LocalAdministrators.ps1
Created September 28, 2020 14:02
Remediate-LocalAdministrators
#Define variables
$currentUser = (Get-CimInstance Win32_ComputerSystem).Username -replace '.*\\'
$localAdministrators = @("[YourGlobalAdminRoleSid]","[YourDeviceAdminRoleSid]") #Adjust to your local administrators
try {
$administratorsGroup = ([ADSI]"WinNT://$env:COMPUTERNAME").psbase.children.find("Administrators")
$administratorsGroupMembers = $administratorsGroup.psbase.invoke("Members")
foreach ($administratorsGroupMember in $administratorsGroupMembers) {
$administrator = $administratorsGroupMember.GetType().InvokeMember('Name','GetProperty',$null,$administratorsGroupMember,$null)
if (($administrator -ne "Administrator") -and ($administrator -ne $currentUser)) {
@pvanderwoude
pvanderwoude / Detect-LocalAdministrators.ps1
Last active April 24, 2024 13:57
Detect-LocalAdministrators
#Define variables
$localAdministrators = @()
$memberCount = 0
$numberLocalAdministrators = 4 #Adjust to your number of administrators
try {
$currentUser = (Get-CimInstance Win32_ComputerSystem).Username -replace '.*\\'
$administratorsGroup = ([ADSI]"WinNT://$env:COMPUTERNAME").psbase.children.find("Administrators")
$administratorsGroupMembers= $administratorsGroup.psbase.invoke("Members")
foreach ($administrator in $administratorsGroupMembers) {
@pvanderwoude
pvanderwoude / New-SettingsTemplate.ps1
Created August 26, 2020 14:29
New-SettingsTemplate.ps1
function Update-PolicySetting {
<#
.SYNOPSIS
A simple function to update policy settings by using MDM WMI Bridge
.DESCRIPTION
This function provides the capability to adjust policy settings by using the MDM WMI Bridge.
It supports the capabilities to create, update and remove an instance
.PARAMETER className
This parameter is required for the name of the WMI class
.PARAMETER parentID
<#
.SYNOPSIS
Configure the Google Chrome Cloud Management enrollment token.
.DESCRIPTION
This script adds a registry key that will set the Google Chrome Cloud Management enrollment token to enable the cloud-based management of the browser.
.NOTES
Author: Peter van der Woude
Contact: pvanderwoude@hotmail.com
Date published: 22-04-2020
Current version: 1.0
<#
.SYNOPSIS
Install Chocolatey packages.
.DESCRIPTION
This script will install Chocolatey packages and provide notifications to the user after succesful installation.
.NOTES
Author: Peter van der Woude
Contact: pvanderwoude@hotmail.com
Date published: 17-04-2019
<#
.SYNOPSIS
Enable Windows Sandbox.
.DESCRIPTION
This script will simply enable the Windows Sandbox for the user.
.NOTES
Author: Peter van der Woude
Contact: pvanderwoude@hotmail.com
Date published: 07-01-2019
Current version: 1.0
<#
.SYNOPSIS
Install Chrome and create the registry key to trigger installation of Chrome extension.
.DESCRIPTION
This script installs Google Chrome by using Chocolatey and creates the registry key that will trigger the installation of the Chrome extension.
This script is created for usage with Microsoft Intune, which doesn't support parameters yet.
.NOTES
Author: Peter van der Woude
Contact: pvanderwoude@hotmail.com
Date published: 02-07-2018