Skip to content

Instantly share code, notes, and snippets.

@r0ckbeard
r0ckbeard / Backup-Template.ps1
Created October 3, 2024 12:25
This script serves as a template for creating backup procedures. It provides a framework for logging, error handling, file compression, and email notifications. Customize the script by adding your specific backup logic in the designated areas.
<#
.SYNOPSIS
Generic Backup Script Template.
.DESCRIPTION
This script serves as a template for creating backup procedures. It provides a framework for logging,
error handling, file compression, and email notifications. Customize the script by adding your specific
backup logic in the designated areas.
.PARAMETER LogFolder
<#
.SYNOPSIS
Transfers members from one Active Directory group to another.
.DESCRIPTION
This script transfers a specified number of members from one Active Directory group to another.
It can be used to stage the move of users from one system to another, facilitating gradual migrations
or testing of new environments with a subset of users.
The script performs the following actions:
1. Transfers specified number of members from a source group to a destination group.
@r0ckbeard
r0ckbeard / Function_Log-Message_CMTraceCompatible.ps1
Created June 13, 2024 09:41
Add logging with CMTrace compatible formatting
<#
.SYNOPSIS
This script initializes a global log file path and provides a function to log messages with different severity levels (Message, Warning, Error).
.DESCRIPTION
The script defines a global variable for the log file path, which is created based on the script's root path or a custom path if provided.
It includes a Log-Message function to log messages to the file and display them in the console with appropriate colors.
The script logs the start time and the end time along with the total execution time.
.PARAMETER LogFilePath
@r0ckbeard
r0ckbeard / Backup-DNSZoneData.ps1
Last active February 20, 2026 15:43 — forked from compwiz32/Backup-DNSZoneData.ps1
DNS backup script with logging and error handling
<#
.SYNOPSIS
DNS Backup Script.
.DESCRIPTION
This script connects to a specified DNS server, retrieves DNS zone and forwarder information, exports the zones and forwarders to files,
compresses the files, and performs cleanup operations. It logs all actions and sends an email notification if an error occurs.
.PARAMETER LogFilePath
The path to the log file where script actions and messages will be recorded. If run from ISE script pane with "Run selection", log file will be saved to C:\Temp\Backup
@r0ckbeard
r0ckbeard / SCCM_ImportDevicesFromCSV-ToDeviceCollection.ps1
Created May 30, 2024 12:55
Imports devices from csv to SCCM/MECM device collection
# Import SCCM module
Import-Module 'C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\ConfigurationManager.psd1'
# Define the Site Code
$SiteCode = ""
# Define the path to the CSV file
$csvPath = ""
# Define the collection ID to which devices will be added
@r0ckbeard
r0ckbeard / SCCM_ImportUsersFromCSV-ToUserCollection.ps1
Created May 30, 2024 12:05
Imports users from csv to SCCM/MECM user collection
# Import SCCM module
Import-Module 'C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\ConfigurationManager.psd1'
# Define the Site Code
$SiteCode = ""
# Define the path to the CSV file
$csvPath = ""
# Define the collection ID to which users will be added
@r0ckbeard
r0ckbeard / Function_Log-Message.ps1
Last active June 13, 2024 09:42
Add logging to your powershell script
<#
.SYNOPSIS
This script initializes a global log file path and provides a function to log messages with different severity levels (Message, Warning, Error).
.DESCRIPTION
The script defines a global variable for the log file path, which is created based on the script's root path or a custom path if provided.
It includes a Log-Message function to log messages to the file and display them in the console with appropriate colors.
The script logs the start time and the end time along with the total execution time.
.PARAMETER LogFilePath