This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Warning: This cleans all profiles STARTING WITH THE USERNAME GIVEN. So "jsmith" would remove "jsmith", "jsmith.domain1.local", "jsmithly" etc. | |
function KillUserProfile { | |
Param ( | |
[Parameter(Mandatory=$True)] | |
[string]$UserName | |
) | |
$profiles = Get-CimInstance win32_userprofile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tests to see if Char value is "empty". | |
# Ran into a need to test for "empty" [Char] DriveLetters when using Get-Partition, | |
# and the usual PS comparison techniques weren't working with Char (ie: Char is never Null). | |
# If you (re)cast it to a Boolean, it'll return expected $True\$False to test for "Empty". | |
# This Gist exists as a reminder of that. | |
function CharIsEmpty { | |
param ( | |
[Parameter(Mandatory=$True)] | |
[char]$CharToTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ComputerIsInGroup { | |
param ( | |
[Parameter(Mandatory=$True)] | |
[string]$GroupName | |
) | |
# Get computer's DN | |
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher | |
$objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry | |
$objSearcher.Filter = "(&(objectCategory=Computer)(SamAccountname=$($env:COMPUTERNAME)`$))" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[int]$DiskNumber = 0 | |
) | |
Write-Host "Gathering SMART info for Disk $DiskNumber..." | |
$disk = Get-Disk $DiskNumber | |
$disk | Get-StorageReliabilityCounter | Select * | FL | |
$partitionsWithDriveLetters = $disk | Get-Partition | Where-Object { [bool]$_.DriveLetter } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################# | |
# Wrapper for Rename-Computer | |
# - Intended to be used with an RMM/automated script launcher. | |
# - DPO, Jan. 2020 | |
################# | |
param ( | |
[Parameter(Mandatory=$True)] | |
[string]$NewName, | |
[Parameter(Mandatory=$True)] | |
[string]$DomainCreds, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-UnlinkedGPOs { | |
[string[]]$results = @() | |
Get-GPO -All | ForEach-Object { | |
if ( $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" ) { | |
$results += $_.DisplayName | |
} | |
} | |
return $results | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-PasswordForDomain { | |
param ( | |
[Parameter(Mandatory=$true)] | |
[string]$Password, | |
[Parameter(Mandatory=$false)] | |
[string]$AccountSamAccountName = "", | |
[Parameter(Mandatory=$false)] | |
[string]$AccountDisplayName, | |
[Microsoft.ActiveDirectory.Management.ADEntity]$PasswordPolicy = (Get-ADDefaultDomainPasswordPolicy -ErrorAction SilentlyContinue) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DiscoWrite { | |
param ( | |
[string]$str, | |
[int]$speed = 25, | |
[switch]$NoNewline | |
) | |
$anim = @('.', '-', '+', '*', '#') | |
[int]$CursorTop = [Console]::CursorTop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$users = Get-ADUser -Server $DomainController -Filter * -Properties Name, DirectReports | |
foreach ($user in $users) { | |
$name = $user.Name | |
foreach ($report in $user.DirectReports) { | |
write-output (("$name, $report").Replace("CN=","") -replace ",OU=.*", "") >> c:\temp\ReportsByUser.csv | |
} | |
} |
OlderNewer