Author Posts

May 13, 2015 at 8:05 am

It's probably the silliest question, but let me still ask. I thought Copy-Item/Move-item commands will always have at least two mandatory parameters, source and destination. But get-help suggests -Destination is an optional parameter. I can't think of any other combinations of copy/move commands without a destination. Can someone please explain?

May 13, 2015 at 8:15 am

The commands will use the current location of the Powershell session as the default destination. So, in the olden days in batch files there was PUSHD or CD to basically change the location of the prompt and then you could use .\ as current directory.

Get-Alias cd

CommandType     Name                                               ModuleName                                                                                                                               
-----------     ----                                               ----------                                                                                                                               
Alias           cd -> Set-Location                                                                                                                                                                          

which allows you to do...

Set-Location C:\BootReport
Get-ChildItem C:\Temp\Test.* | Copy-Item 

May 13, 2015 at 9:01 am

That explains. Thanks Rob. Silly me...!