An obvious attempt would be to simply indicate the path to the variable:
PS Home:\> $xmldata = gci | ConvertTo-Xml PS Home:\> Import-Clixml Variable:\xmldata Import-Clixml : Cannot open file because the current provider (Microsoft.PowerShell.Core\Variable) cannot open a file. At line:1 char:14 + Import-Clixml <<<< Variable:\xmldata + CategoryInfo : InvalidArgument: (:) [Import-Clixml], PSInvalidOperationException + FullyQualifiedErrorId : ReadWriteFileNotFileSystemProvider,Microsoft.PowerShell.Commands.ImportClixmlCommand
... which sadly fails. Therefore, I would suggest that there really is no way to work without temporary files.
The main theme of ConvertTo-XML is the ability to further process XML in PowerShell after converting the object to XML. So the question is, why can't you just make changes to the object directly, and not manipulate XML and transform it?
Otherwise, you can put temporary files in a function.
source share