Copy/Move without Destination parameter

Welcome Forums General PowerShell Q&A Copy/Move without Destination parameter

This topic contains 2 replies, has 2 voices, and was last updated by

GJ
 
Participant
3 years, 8 months ago.

  • Author
    Posts
  • #25169
    GJ

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 429
    Helping Hand
    Rank: Contributor

    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
    GJ

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Copy/Move without Destination parameter’ is closed to new replies.