I need to dynamically build a string parameter using output from a pipe which is then passed to another command.
The source command is Get-VM which has an element called Name
The destination command is Move-VM, which accepts a parameter of -DestinationStoragePath
I need to dynamically manipulate this path based on the source Name to be D:\{0} where {0} is the VM Name.
I have this so far:
Get-VM | Move-VM -DestinationStoragePath [string]::Format("D:\{0}",$_.Name)
But it is throwing an exception, if i statically set the DestinationStoragePath parameter, then it works fine, so its just this little bit that is tripping it up.
Any ideas?