Copy/Move without Destination parameter

This topic contains 2 replies, has 2 voices, and was last updated by  GJ 3 years, 1 month ago.

  • Author
  • #25169


    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?

  • #25170

    Rob Simmers

    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 
  • #25175


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

You must be logged in to reply to this topic.