Skip to content

Instantly share code, notes, and snippets.

View compwiz32's full-sized avatar

Mike Kanakos compwiz32

View GitHub Profile
@compwiz32
compwiz32 / Backup-DNSZoneData.ps1
Last active November 29, 2023 04:55
DNS backup script
#Set file paths for later use
$BackupFolder = "ServerName\ShareName" # use a valid path like "\\Server01\Backups\DNSBackup"
$DNSServer = "ServerName"
$Credential = Get-PSCredential
# connect to DC as another user
$CIMSession = New-CimSession -ComputerName $DNServer -credential $Credential #Use MS Secret Mgmt to manage your credentials
#Read DNS info from DC
$ShortDate = Get-Date -Format "yyyy-MM-dd"
Describe "Local Machine Health Check" {
$date = Get-Date
Context "Hardware Health Checks" {
It "C Drive has more than 1 GB free" {
$diskinfo = Get-CimInstance win32_volume | Where-Object { $_.driveletter -like 'c:' }
$DiskFreeSpace = $([math]::round((($diskinfo.FreeSpace)/1GB),0))
$DiskFreeSpace | Should BeGreaterThan 1
}
@compwiz32
compwiz32 / New-PassPhrase.ps1
Last active September 5, 2021 01:16
Generate Strong Passphrases
#Requires -Module NameIT
function New-PassPhrase {
[CmdletBinding()]
param (
[Parameter()]
[int]
$MinPasswordLength = 10,
[Parameter()]
@compwiz32
compwiz32 / Prompt.ps1
Last active November 19, 2022 05:26
Script for article - "Customize your PowerShell commnd prompt"
function prompt {
#Assign Windows Title Text
$host.ui.RawUI.WindowTitle = "Current Folder: $pwd"
#Configure current user, current folder and date outputs
$CmdPromptCurrentFolder = Split-Path -Path $pwd -Leaf
$CmdPromptUser = [Security.Principal.WindowsIdentity]::GetCurrent();
$Date = Get-Date -Format 'dddd hh:mm:ss tt'
@compwiz32
compwiz32 / Get-NestedGroup.ps1
Last active September 7, 2020 22:33
Script for article at 4sysops.com
function Get-NestedGroup {
<#
.SYNOPSIS
Gets a list of nested groups inside an Active Directory group
.DESCRIPTION
Gets a list of nested groups inside an Active Directory group using LDAPFilter. Checks for
two levels of nested groups from the parent group.
.PARAMETER Group
The name of an Active Directory group
@compwiz32
compwiz32 / Get-ADObjectOwner.ps1
Created August 25, 2020 14:02
script posted at networkadm.in
function Get-ADObjectOwner {
<#
.SYNOPSIS
Retrieves the owner information of an object from Active Directory
.DESCRIPTION
Retrieves the owner information of an object from Active Directory. Can find the owner info for a user,
computer, group or diistinguished name.