copy-item question

Welcome Forums General PowerShell Q&A copy-item question

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

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #156675

    Participant
    Topics: 5
    Replies: 7
    Points: 46
    Rank: Member

    I've got the below code and I would like to change the last line of code so that the I get something like -destination  $path $file

    but when trying this it doesn't seem to work can you help me out here

    $path= "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile\"
    $file="VPN.xml"
    if(!(Test-path -Path $path)){New-Item -ItemType directory -path $path}
    if(!(Test-Path -Path $file)){Copy-Item -Path C:\Users\$env:USERNAME\Downloads\$file -Destination C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile\,$file}
    

     

    thanks

     

  • #156693

    Participant
    Topics: 1
    Replies: 1481
    Points: 2,366
    Helping Hand
    Rank: Community Hero
    $path = "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile"
    $file = "C:\Users\$env:USERNAME\Downloads\VPN.xml"
    if (!(Test-path -Path $path)) { 
        New-Item -ItemType directory -path $path 
    }
    if (!(Test-Path -Path $file)) { 
        Copy-Item -Path $file -Destination $path
    }

    ...should work like this ...

  • #156831

    Participant
    Topics: 5
    Replies: 7
    Points: 46
    Rank: Member

    Olaf thanks for your help

     

    Paul

     

The topic ‘copy-item question’ is closed to new replies.