Skip to content

Instantly share code, notes, and snippets.

@automationhaus
automationhaus / Write-Tee.ps1
Last active December 16, 2016 15:16
Write Output to the Screen and to File
function Write-Tee
{
<#
.SYNOPSIS
Write output to the screen and to file simultaneously
.DESCRIPTION
Simply write your screen output to a file with automatic coloring based with special sytax between square brackets. Enable debugging and produce debugging only ouptut.
.EXAMPLE
Write-Tee "[=] This is the first task in my loop"
.EXAMPLE
@automationhaus
automationhaus / Remove-UserProfilesRemote.ps1
Last active January 21, 2017 02:00
Remotely Remove User Profiles from RDS or Citrix Session Host Servers
<#
I broke out the Get-CIMInstance and Get-WMIObject types for a couple of reasons. 1. Because I kept running into issues on 2008 R2
where CIM wasn't working due to the fact they aren't configured for remoting out of the box like 2012 servers are. 2. In order to
train system admins on how to use both versions in case one or the other doesn't work for them. Here, I break down the two based
on the version of the OS but you can elect to use one or the other depening on your environment. In CIM you can specify the protocol
type which could help eliminate the need for the WMI version but the WMI version will be supported on servers with older versions
of PowerShell.
#>
#Specifying the EAP
$ErrorActionPreference = "Stop"
@automationhaus
automationhaus / Remove-UserProfiles.ps1
Created November 4, 2016 12:28
PowerShell script to remove user profiles from Citrix or RDS session host servers
$Exclusions = "NetworkService","LocalService","systemprofile"
Get-CimInstance win32_UserProfile | ?{$Exclusions -notcontains $(Split-Path -Path $_.LocalPath -Leaf)} | Remove-CimInstance