I have a Powershell script which does a lot of things and one of them is moving files:

$from = $path + '\' + $_.substring(8)
$to   = $quarantaine + '\' + $_.substring(8)

Move-Item $from $to

But it happens the directory structure isn't already present in the $to path. So I would like Powershell to create it with this commando. I've tried Move-Item -Force $from $to, but that didn't help out.

What can I do to make sure Powershell creates the needed directories in order to get things working?
I hope I make myself clear, if not, please ask!

You could also add a utility function like this:

Function Move-Item-Parent([string]$path, [string]$destination) {
    New-Item $destination -ItemType Directory -Force
    Move-Item $path $destination
}

Then invoke it like this:

Move-Item-Parent $from $to