PoshCode Archive  Artifact [6893633f8a]

Artifact 6893633f8a7187392eb87d47b8afb20892d92398945ac37a391c3874c047cf06:

  • File Bulk-Delprof.ps1 — part of check-in [c9ef72bb8e] at 2018-06-10 14:12:24 on branch trunk — This script provides a way to bulk delete profiles on a system. Utilizes the Delprof2.exe program. (user: AlphaSun size: 1268)

# encoding: ascii
# api: powershell
# title: Bulk Delprof
# description: This script provides a way to bulk delete profiles on a system. Utilizes the Delprof2.exe program.
# version: 0.1
# author: AlphaSun
# license: CC0
# x-poshcode-id: 6296
# x-archived: 2017-04-30T12:15:28
# x-published: 2017-04-08T21:32:00
#
# As configured below, the script will only LIST accounts in a “WhatIf” style. To actually perform the Delprof, remove the comment on Line 14.
#
# Prompt for Search String
$Input = Read-Host	'Dot-sourced path to input file (eg .\Targets.txt)'
Write-Host		' '
Write-Host		'Wildcard characters * and ? can be used in the pattern'
Write-Host		' '
$Include = Read-Host	'Include profiles that match this naming pattern'
$Exclude = Read-Host	'Exclude profiles that match this naming pattern'

$Date = Get-Date -Format yyyyMMdd.hhmm
$Targets = Get-Content $Input
foreach ($target in $Targets) {

	delprof2 /l /c:\\$target /ed:$Exclude /id:$Include >> .\Delprof_$Date.log	## LIST profiles
	# delprof2 /c:\\$target /ed:$Exclude /id:$Include >> .\Delprof_$Date.log	## REMOVE profiles
}

# Wait for user acknowledgement
Write-Host -NoNewLine "Press any key to continue..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")