TL;DR
You are not using DropTree but DropLink. I don't think you can set null value for DropLink type. It has always some value (clearing it on client side input won't change anything)
Read more because there is a solution for that
Why Mandatory is not working
Mandatory field should work fine anyway. The reason your value for $item
variable is never null/empty is fact that you are assigning default value at the beginning
$item = Get-Item master:\content\home
Change it to
$item = $null
in your initial implementation and you will see that validation with Mandatory
parameter work, though this field will not be DropLink anymore, it is SingleLineText
now (I am not sure, maybe we should report this to SPE team?).

How to solve the problem
Default field used in you case is DropLink. We have to declare that we want to use DropTree explicitly.
Steps:
- Add Additional parameter
editor="DropTree"
to your item variable
- Switch
Root
parameter name to Source
From now on you can set empty value for your item selector.
Complete example:
In this example you can see how to use Mandatory
parameter and -Validator
switch at the same time.
$item = Get-Item "master:\content\home"
$item = $null
$result = Read-Variable -Parameters `
@{ Name = "token"; Value = "Token"; Title = "Value to be replaced"; Tooltip = "Value to be replaced"; Placeholder = "Inform what text you want to replace"; Mandatory = $true },
@{ Name = "replaceWith"; Value = "Replace With"; Title = "New value"; Tooltip = "New Value"; Placeholder = "Inform the new value"; Mandatory = $true },`
@{ Name = "item"; editor="DropTree";Title = "Select the root item. It will apply to all it's descendants"; Root = "/sitecore/content/"; Mandatory = $true } `
-Description "This Dialog shows less editors, it doesn't need tabs as there is less of the edited variables" `
-Title "Initialise various variable types (without tabs)" -Width 500 -Height 480 `
-OkButtonName "Proceed" -CancelButtonName "Abort" `
-Validator {
$itemVariable = $variables.item.Value
if ($itemVariable.ID -eq "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}")
{
$variables.item.Error = "Please select different root item"
}
}

Summary
Validator feature is available for SPE 4.2+
Links