Set “Out of Office” on Mailbox with PowerShell

Dates are 6th April 2021 to 7th April 2021 and are always in American format (mm/dd/yyyy)

Uses email address

Set-MailboxAutoReplyConfiguration -identity mary.raymond@XYZ.com -AutoReplyState scheduled -starttime “04/06/2021” -endtime “04/07/2021 08:00:00” -ExternalAudience all -InternalMessage $message -ExternalMessage $message

Set-MailboxAutoReplyConfiguration -identity Emma.johnson@xyz.co.uk -AutoReplyState scheduled -starttime “04/06/2021” -endtime “04/07/2021” -ExternalAudience all -InternalMessage “I am currently out the office and will be returning on 7th April 2021.” -ExternalMessage “I am currently out the office and will be returning on 7th April 2021.”

Uses mail alias

Set-MailboxAutoReplyConfiguration <alias> -AutoReplyState enabled -ExternalAudience all -InternalMessage “This email address is no longer in use. Please email jimmy.parker@XYZ.com, Thanks” -ExternalMessage “This email address is no longer in use. Please email jimmy.parker@XYZ.com, Thanks”

Set-MailboxAutoReplyConfiguration <alias> -AutoReplyState scheduled -starttime “04/06/2021” -endtime “04/07/2021” -ExternalAudience all -InternalMessage “I’m currently out of the office and this mailbox is not being monitored. If you have any queries which need responding to please contact my manager Mark Mende by email mark.mende@xyz.co.uk” -ExternalMessage “I’m currently out of the office and this mailbox is not being monitored. If you have any queries which need responding to please contact my manager Mark Bloggs by email mark.bloggs@xyz.co.uk

If part of the message has a $ sign – Use single quotes instead of double quotes

Set-MailboxAutoReplyConfiguration -identity risk@xyz.com -AutoReplyState enabled -ExternalAudience all -InternalMessage  ‘Thank you for your mail. Please note that this is an unmonitored mail box. Please redirect your mail to $Risk@xyz.com‘ -ExternalMessage ‘Thank you for your mail. Please note that this is an unmonitored mail box. Please redirect your mail to $Risk@xyz.com

To check your results afterwards: 

Get-MailboxAutoReplyConfiguration –Identity  servicing@xyz.co.uk

To turn off auto-replies

Set-MailboxAutoReplyConfiguration -Identity <alias or email> -AutoReplyState disabled

To turn off auto-replies and clear the reply text

Set-MailboxAutoReplyConfiguration <alias or email> –AutoReplyState Disabled –ExternalMessage $null –InternalMessage $null

HTML Multiline Message, use <br> tags for line breaks

Set-MailboxAutoReplyConfiguration -identity <alias or email> -AutoReplyState enabled -ExternalAudience all -InternalMessage “This mailbox is currently closed and is not monitored.<br><br>Please contact the Service Desk using your company’s number below..<br><br>XYZ Europe: +01 123 456 7890 <br><br>Alternatively  please log your issue on Service Desk Online through your company Intranet.” -ExternalMessage “”This mailbox is currently closed and is not monitored.<br><br>Please contact the Service Desk using your company’s number below..<br><br>XYZ Europe: +01 123 456 7890 <br><br>Alternatively  please log your issue on Service Desk Online through your company Intranet.”

PowerShell: Capture Network Traces

<#
.SYNOPSIS
Capture Traces with Wireshark in PowerShell

.DESCRIPTION

#############################################################
# #
# Capture network traces in PowerShell #
# Circular tracing #
# #
# #
# #
# (C)Citrix EMEA Escalation Team #
# #
# David Cristobal #
# #
#############################################################

Script to automate tracing with Wireshark using PowerShell, when GUI cannot be used

CaptureNetworkTraces.ps1 -FileName <[string]> -WiresharkPath <[string]> -NumberOfFiles <[string]> -FileSize <[string]> -TimeToStart <[string]> -RecheckTime <[string]> -CircularTraces

-FileName <File Name>
Name for the files, If null, will use the computer’s name and the date

-WiresharkPath <Wireshark installation path>
As this script relies in Wireshark binaries, the path is needed. If it’s installed in a different drive, you can specify it with this parameter

-NumberOfFiles <>
Number of files. If none given, will use 5

-FileSize
Size of every file in Kb. If none is given, will use 100Mb

-TimeToStart
Time to start tracing in format HHMM (like 2230 for 23:30 or 0845 for 8:45)

-RecheckTime
In case delayed start set, interval to check if the time has yet reached in seconds

-CircularTraces
Set traces as circular, ring buffer

.EXAMPLE
CaptureNetworkTraces.ps1 -FileName Trace001 -NumberOfFiles 4

Capture 4 files named Trace001.pcapng to Trace004.pcapng, 100Mb each (default value)

.EXAMPLE
CaptureNetworkTraces.ps1 -FileName Trace001 -FileSize 10000 -CircularTraces

Capture 5 files (default value) named named Trace001.pcapng to Trace005.pcapng, 10Mb each, in circualr tracing (until Ctrl+C is pressed)

.EXAMPLE
CaptureNetworkTraces.ps1 -NumberOfFiles 10 -FileSize 10000 -TimeToStart 2230 -RecheckTime 60

Capture 10 files 10Mb each with name ServerDate.pcapng (default), starting the trace at 22:30 and checking it every 60 seconds

#>

##Paramaters for the script
param
(
[Parameter(Mandatory=$false)][string]$FileName,
[Parameter(Mandatory=$false)][string]$WiresharkPath,
[Parameter(Mandatory=$false)][string]$NumberOfFiles,
[Parameter(Mandatory=$false)][string]$FileSize, ## In Kb
[Parameter(Mandatory=$false)][string]$TimeToStart, ## Format HHmm (Hours, minutes)
[Parameter(Mandatory=$false)][string]$RecheckTime, ## In seconds
[Parameter(Mandatory=$false)][switch]$CircularTraces ## Circular tracing
)

#region Variables
$Delay=$False
#endregion

#region Sanity checks

## Check if Filename is provided
if (!$FileName) ## If Filename is not provided, generate one withe date and time
{
$Filename=($env:computername)+”-“+(Get-Date -format yyyyMMdd-HHmmss)
}

$Filename=$Filename+”.pcapng” ## Add the Wireshark extension ot the file

## Check if Number of files is set
if (!$NumberOfFiles) ## If not set, 5 by default
{
$NumberOfFiles=”5″
}

## Check if Size of files is set
if (!$FileSize) ## If not set, 100Mb by default
{
$FileSize=”100000″
}

## Check if time to start is set is set
if (![string]::IsNullOrEmpty($TimeToStart))
{
if ((![string]::IsNullOrEmpty($TimeToStart)) -AND ($TimeToStart.Length -eq 4) -AND ($TimeToStart -match ‘[0-9]{4}’) -AND ([convert]::ToInt32($TimeToStart,10) -lt “2400”))
{
Write-host “Delayed start set for “$TimeToStart.Substring(0,2)”:”$TimeToStart.Substring(2,2)
$Delay=$true
Write-host “`n”

## Check if time to recheck delayed start is set
if ((![string]::IsNullOrEmpty($RecheckTime)) -AND ([Helpers]::IsNumeric($RecheckTime)))
{
Write-host “Timeout to recheck delayed start set to $RecheckTime seconds”
}
else
{
Write-host “Timeout to recheck delayed start not set”
Write-host “Default to 1 minute, 60 seconds”
$RecheckTime=60
}
}
else
{
Write-host “Incorrect time to start the trace” -foregroundcolor red
Write-host “Time needs to be set as HHmm (Hours,Minutes) and less that 2400”
Write-host “`n”
exit
}
}

## Check if Wireshark is installed
if (!$WiresharkPath) {$WiresharkPath = “C:\Program Files\Wireshark”}

if (Test-Path $WiresharkPath)
{
Write-Host “Wireshark found in the machine”
Write-host “`n”
}
else
{
Write-Host “Wireshark is not installed in the machine!!!” -foregroundcolor red -backgroundcolor yellow
Write-Host “If it’s not installed in the default path, use the -WiresharkPath parameter” -foregroundcolor red -backgroundcolor yellow
Write-Host “Stopping script” -foregroundcolor red -backgroundcolor yellow
Write-host “`n”
Write-host “Press Any Key To Exit….”
cmd /c pause | out-null
exit
}

# Verification and creation of the tshark Alias
if(Get-alias -name tshark*)
{
Write-Host “Tshark alias exists”
Write-host “`n”get-help
}
else
{
Write-Host “Tshark alias doesn’t exist. Creating it…”
new-alias tshark $WiresharkPath’\tshark.exe’
Write-host “Tshark alias created”
Write-host “`n”
}

# Verify if Wireshark path in the Path variable and adding it if needed
if($env:Path -like ‘*’+$WiresharkPath+’*’)
{
Write-Host “Wireshark path already in path variable”
Write-host “`n”
}
else
{
Write-Host “Wireshark path not found in Path variable. adding it…”
$env:Path += “;C:\Program Files\Wireshark\”
Write-Host “Wireshark path added”
Write-host “`n”
}

# Check if the trace is circular

if ($CircularTraces)
{
$CircularFlag = “-b”
}

#endregion

#region Wrap up parameters and show them on screen
Write-Host “Parameters for the trace” -foregroundcolor DarkRed
Write-Host “========================” -foregroundcolor DarkRed
Write-Host “Filename that will be used: ” -foregroundcolor green -nonewline
Write-Host $FileName -foregroundcolor gray
Write-Host “Number of files that will be kept: ” -foregroundcolor green -nonewline
Write-Host $NumberOfFiles -foregroundcolor gray
Write-Host “Size of every file: ” -foregroundcolor green -nonewline
Write-Host ($FileSize/1000)”Mb” -foregroundcolor gray
Write-Host “Path for Wireshark: ” -foregroundcolor green -nonewline
Write-Host $WiresharkPath -foregroundcolor gray
Write-host “`n”
Write-host “To stop the trace at any time, press Ctrl + C” -foregroundcolor red
Write-host “`n”
#endregion

#region Capture traces

## Check delayed start
while (($Delay -eq $True) -AND ((Get-Date -format HHmm) -ne $TimeToStart))
{
Write-Host “Time to start tracing not reached yet.”
Write-host “Actual time”(Get-Date -format HHmmss)
Write-Host “Expected time to start: “$TimeToStart
Start-Sleep -s $RecheckTime
}

## Start tshark with parameters
tshark.exe -w $FileName $CircularFlag filesize:$FileSize -b files:$NumberOfFiles

#endregion

Find and delete all versions of Citrix Receiver manually using batch file

Note: you will need msizap.exe. It not available from Microsoft anymore but if you Google it you’ll find it.

@echo off
taskkill /IM AuthManSvr.exe /F > nul 2>&1
taskkill /IM concentr.exe /F > nul 2>&1
taskkill /IM wfcrun32.exe /F > nul 2>&1
taskkill /IM wfica32.exe /F > nul 2>&1
taskkill /IM redirector.exe /F > nul 2>&1
taskkill /IM Receiver.exe /F > nul 2>&1
taskkill /IM SelfService.exe /F > nul 2>&1
taskkill /IM SelfServicePlugin.exe /F > nul 2>&1
taskkill /IM ssonsvr.exe /F > nul 2>&1
taskkill /IM pnamain.exe /F > nul 2>&1
taskkill /IM updater.exe /F > nul 2>&1
taskkill /IM radeobj.exe /F > nul 2>&1

REM Uninstall Citrix XenApp Plugin for Hosted Apps 11.0.0.5357 and delete reg-keys from HKLM\Software\classes.

MsiExec.exe /I{388C130B-0079-46B4-A0D5-DC2DD7A89A7B} /quiet
REM For Citrix XenApp Plugin for Hosted Apps 11.0.0.5357.
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\F3BEEFBEB3E352744A0E731644ECF467” /f
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\B031C88397004B640A5DCDD27D8AA9B7” /f
REM removes web-plugin 11.0.0.5357
MsiExec.exe /I{EBFEEB3F-3E3B-4725-A4E0-376144CE4F76} /quiet

REM Uninstall Citrix Online Plug-In 12.3.0.8 and delete reg-keys from HKLM\Software\classes

“C:\ProgramData\Citrix\Citrix online plug-in – web\TrolleyExpress.exe” /uninstall /cleanup
rmdir “C:\ProgramData\Citrix\Citrix online plug-in – web” /Q /S

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\1C0AEE1BC1B655A48839E41CC028712D” /f
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\58674D61A657DF64890833ADB6A496AE” /f

REM Remove folder from c: drive
rmdir “C:\Program Files (x86)\Citrix\ICA Client” /Q /S

REM Citrix online plug-in (SSON) 12.3.0.8
MsiExec.exe /I{0F7319A9-083D-40B3-8256-00A6F3C2AAA2} /quiet

REM USB 12.3.0.8
MsiExec.exe /I{133236FE-E2F7-4313-8BF8-A10ACAAA7CB9} /quiet

REM web 12.3.0.8
MsiExec.exe /I{2FC7287D-39DD-4A84-9806-D27D3CCDC51B} /quiet

REM hdx 12.3.0.8
MsiExec.exe /I{57287FDF-27E6-45BC-9DD2-A33545C46C1A} /quiet

REM dv 12.3.0.8
MsiExec.exe /X{6F2FDD50-E0F3-4117-B575-78E77F8D11EF} /quiet

REM Delete regkeys.
REM DV
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\05DDF2F63F0E71145B57877EF7D811FE” /f
REM hdx
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\FDF782756E72CB54D92D3A53544CC6A1” /f
REM pna
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\3D8773198D1E55B4296433805CD41326” /f
REM sson
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9A9137F0D3803B042865006A3F2CAA2A” /f
REM usb
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\EF6323317F2E3134B88F1AA0ACAAC79B” /f
REM web
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\D7827CF2DD9348A489602DD7C3DC5CB1” /f

REM In version 12.3.0.8 there is a %programdata%-folder so run:
“C:\ProgramData\Citrix\Citrix online plug-in\TrolleyExpress.exe” /uninstall /cleanup
rmdir “C:\ProgramData\Citrix\Citrix online plug-in” /Q /S

REM Uninstall Citrix Receiver 14.4. The ReceiverCleanupUtility.exe removes a lot but we manually remove these reg keys.

REM aero
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\39209FA8EAE95134699BB68CB81B2D64” /f
REM authentication
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\C32044992FE99DC4BBE6CD0198F542B6” /f
REM Citrix inside
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\2E00671D2CFD34240A5726B1CAEE20C5” /f
REM webhelper
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\DDF5F12BD35BE384B9BE4B9AB77F49F2” /f
REM dv
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\FCD2A818A53A67148AE4601FB9F05F71” /f
REM hdx-flash
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\30CA808B063E4CF46AA66C4166225CB5” /f
REM selfservice
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\277BF9E19A51770439C4119C7219D9D7” /f
REM SSON
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\C4B86096242698648B5E511A8E62DB1A” /f
REM USB
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\14355E4666DF3804F94F374E1FA99AEC” /f

REM Online Plug-in 14.4.0.8014.
MsiExec.exe /I{3D6AA3F8-2977-474E-95EB-4058983C4C0F} /quiet
REM online plug-in
reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\8F3AA6D37792E47459BE048589C3C4F0” /f

REM If there are any other Citrix-versions this loop will find it and uninstall it. Msizap.exe is already locally stored on our machines in C:\Windows.

del guids.txt
:: Find the text-file. If not – create a new one.

FOR /F “skip=2 tokens=2,*” %%A IN (‘reg.exe query “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix\PluginPackages\XenAppSuite” /s /v “ProductCode”‘) DO echo %%B>>guids.txt

for /f %%a in (guids.txt) do msiexec.exe /X %%a /quiet

for /f %%a in (guids.txt) do C:\Windows\msizap.exe TWA! %%a

Seach Registry Using Batch File

Example for searching Citrix Receiver install GUIDs and outputting to a text file.

del guids.txt

:: If txt file exists. We want a fresh one to hold the guids.

FOR /F “skip=2 tokens=2,*” %%A IN (‘reg.exe query “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix\PluginPackages\XenAppSuite” /s /v “ProductCode”‘) DO echo %%B>>guids.txt