So I love that you can pipe in and out of things so smoothly in PowerShell. But what if that piping needed to be stored externally and brought back in by another script or even another computer?
I thought CLIXML was the key but I guess it's not working the way I want.
Take the following example:
Get-Printer | Where {($_.PortName -match "10.110.") -and ($_.Type -match "Connection")} | Export-Clixml -Path ($OutputPath + "\MappedPrinters.XML")
I would hope that this command would work as one might expect:
Import-Clixml -Path ($OutputPath + "\MappedPrinters.XML") | Add-Printer
But that results in several instances of this error:
Add-Printer : One or more parameter values passed to the method were invalid.At line:1 char:61
+ Import-Clixml -Path ($OutputPath + "\MappedPrinters.XML") | Add-Printer
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Add-Printer], CimException
+ FullyQualifiedErrorId : MI RESULT 4,Add-Printer
Is there a way that this should work when we need to save some objects for later use?