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
1 week, 4 days ago.

  • Author
    Posts
  • #156675

    Participant
    Topics: 2
    Replies: 2
    Points: 14
    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: 1333
    Points: 1,690
    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: 2
    Replies: 2
    Points: 14
    Rank: Member

    Olaf thanks for your help

     

    Paul

     

You must be logged in to reply to this topic.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort