Copy/Move without Destination parameter

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of GJ GJ 2 years, 2 months ago.

  • Author
    Posts
  • #25169
    Profile photo of GJ
    GJ
    Participant

    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
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    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
    Profile photo of GJ
    GJ
    Participant

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

You must be logged in to reply to this topic.