Skip to content

Instantly share code, notes, and snippets.

@RaRaRatchet
RaRaRatchet / Get-PendingReboot.ps1
Last active March 19, 2024 05:38
[Get-PendingReboot] #TS
$RebootPending = $false
#Check for 'Reboot Required' registry key
if(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ea SilentlyContinue) {
$RebootPending = $true
@RaRaRatchet
RaRaRatchet / Mount-StdUser
Last active January 17, 2024 06:37
[PSDrive]
$cred = Get-credential
New-PSDrive -Name mounted_dokumente -PSProvider FileSystem -Credential $cred -Root "XXXXXXXXXXXXX"
## Set logging variables:
$script_log_dir = "C:\Logs"
$script_name = $MyInvocation.MyCommand.Definition | Split-Path -Leaf
$script_short_name = $script_name.split(".")[0]
$script_path = $MyInvocation.MyCommand.Definition | Split-Path -Parent
$script_registry_hive = "HKLM:\Software\HG3"
$script_logfile = $script_log_dir + "\" + $script_short_name + ".log"
$script_logfile_with_date = $script_log_dir + "\" + $script_short_name + "-" + (Get-Date -Format yyyy-MM-dd) + ".log"
$script_logging_enabled = $false
@RaRaRatchet
RaRaRatchet / CleanUp-ISE-Session.ps1
Created December 6, 2022 17:27
CleanUp-ISE-Session
Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear();
@RaRaRatchet
RaRaRatchet / PSReadline.ps1
Last active December 6, 2022 17:57
[Powershell Modules - Installation and Configuration] Modules and Module Configurations for Powershell #PS #Modules
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineOption -Colors @{emphasis = '#ff0000'; inlinePrediction = 'magenta'}
Set-PSReadLineOption -HistoryNoDuplicates
@RaRaRatchet
RaRaRatchet / Get-Drivers
Created July 13, 2022 06:50
[Get-Drivers] Get installed Drivers from Win32
Get-WMIObject Win32_PnPSignedDriver | where {$_.Devicename -like "*Realtek*"} | select-object -Property * | Export-CSV ZBNB31156_RealtekDriver.csv
Get-WMIObject Win32_PnPSignedDriver | where {$_.Devicename -like "*Smart*"} | select-object -Property * | Export-CSV -Path ZBNB31156_Driver_SmartSound.csv
@RaRaRatchet
RaRaRatchet / Get-ADComputer-Win8.ps1
Last active January 17, 2024 12:28
[Active Directory] #AD #ADGroups # #OUs
Get-ADComputer -Filter 'operatingsystem -like "Windows 8*" -and enabled -eq "true"' `
-Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address,LastLogonDate | Select-object -Property Name
@RaRaRatchet
RaRaRatchet / Clean-MacAddress.ps1
Created November 18, 2021 20:31
[Verify-MacAddress]
function Clean-MacAddress {
<#
.SYNOPSIS
Function to cleanup a MACAddress string
.DESCRIPTION
Function to cleanup a MACAddress string
.PARAMETER MacAddress
Specifies the MacAddress
.PARAMETER Separator
Specifies the separator every two characters
@RaRaRatchet
RaRaRatchet / CheckIfInventoryNumber.ps1
Created November 6, 2021 09:26
[Input Validation] Validate different types of input #powershell #validate
## Input validation
## Convert String to Int and check if valid Int Number
[int]$number = "12345"
if ($number -is [int]){
$NumberIsIntValue = $true
}
@RaRaRatchet
RaRaRatchet / Get-SCCMCollectionsInFolder.ps1
Last active March 9, 2026 18:11
[Get All DeviceCollections in a Folder ] Get Folder Details and get Collections in a Folder #powershell #ConfigurationManager #SCCM
Function Get-SCCMCollectionsInFolder
{
<#
.SYNOPSIS
Returns all the collections located in the specified folder ID.
.DESCRIPTION
Connects to the specified site server and retrieves the details of the specified folder as output that in term can be used for other functions.
This function is usable for Device or User collections any other items will need different WMI queries and these would be best added to a seperate function.
.EXAMPLE