copy one folder

This topic contains 33 replies, has 4 voices, and was last updated by  cosmic 3 months ago.

  • Author
    Posts
  • #79001

    cosmic
    Participant

    I want to write a script to check the folder for a server, and then another folder to check it in the folder, and if this folder exists, copy that folder to the other server from that server!
    For example, when we run the script, we will use the name of the first folder, then if there is a folder name that you have in that folder, and if there is one to copy it, if it does not exist, it says there is no folder.

  • #79010

    Olaf Soyk
    Participant

    And what is the question? 😉

  • #79015

    Max Kozlov
    Participant

    2b|!2b

    • #79046

      Kevyn
      Participant

      I think you mean:

      $2b -or !$2b

      🙂

  • #79048

    Kevyn
    Participant

    Cosmic, can you give us specific examples of what you're talking about, including folder paths/names, server names, etc....

    Ex:

    If folder "C:\blah" exists on Server1 & folder blah2 exists in it (i.e. C:\blah\blah2 exists), then copy folder blah2 from Server1 to another folder called remote_blah on Server2 (\\Server2\remote_blah).

    Something like that.

  • #79066

    cosmic
    Participant

    how can I writing a script that say one special folder(testfolder2) exist in a path:d:\dokument\test\2017 on server? and then copy this folder to 10 diffrent server
    catalog names are not the same all the time and each time we have another name! next time testfolder3 becomes! I thought to use then first and when I write the folder names then look for folder in the path! $foldername = Read-Host "Enter folder to check"

  • #79067

    Olaf Soyk
    Participant

    You can check the existence of a file system object with Test-Path. You can copy file system objects with Copy-Item. And you can repeat a particular action with one of the in Powershell available loop constructs like Foreach or Foreach-Object.

    We cannot write scripts for you. If you have a specific question to a particular piece of code you wrote you're welcome to post this here and we can try to help you with this.
    If you're looking for prewritten scripts you can try here: https://gallery.technet.microsoft.com/scriptcenter or here: https://www.powershellgallery.com/

  • #79073

    cosmic
    Participant

    $folder1 = Read-Host "Enter folder to check"
    $foldername = "D:\CosmicInst\R8\$folder1"
    #set folder you want to check for

    $folder2 = Read-Host "Enter folder to check"
    $foldername2 = "D:\CosmicInst\R8\$folder1\$folder2"

    $source = "D:\CosmicInst\R8\$folder1\$folder2\Products\Manualhandling\IX3"
    $destination = "C:\Users\baa065sa\Powershell skript\$Destination"

    $path = Test-Path $source
    If ($path){Copy-Item $source -Destination "$destination" -Recurse}

  • #79079

    Olaf Soyk
    Participant

    Please format your code as code!
    You create variables and you don't use it. What for? And then you create a variable and use this variable to create it. If that really works (I did not try to test this) it will probably produce unpredictable results. Something like this should actually work:

    $folder1 = Read-Host "Enter folder to check"
    $folder2 = Read-Host "Enter folder to check"
    $source = "D:\CosmicInst\R8\$folder1\$folder2\Products\Manualhandling\IX3"
    $destination = "C:\Users\baa065sa\Powershell skript\"
    If (Test-Path $source){
        Copy-Item $source -Destination "$destination" -Recurse
    }
  • #79082

    cosmic
    Participant

    I will check if folder1 exist or not exist in sourc! And I will check If folder1 exist or not exist in distans!
    if not exist I will create folder1 and folder2 in destans! distans iz 10 diffrent servers!

  • #79085

    cosmic
    Participant
    $folder1 = Read-Host "Enter folder to check"
    $foldername1 = "D:\test\R8\$folder1"
    If (test-path $foldername1) {Write-Host "folder exists on Server." -ForegroundColor Green}
    Else {Write-Host "folder NOT exist on Server." -ForegroundColor Red}
    
    		
    
    $folder2 = Read-Host "Enter folder to check"
    $foldername2 = "D:\test\R8\$folder1\$folder2" 
    If (test-path $foldername2) {Write-Host "folder exists on Server." -ForegroundColor Green}
    Else {Write-Host "folder NOT exist on Server." -ForegroundColor Red}
    
    
    $serverlist1 = Get-Content 'C:\Users\test\Powershell skript\testservrar2.txt'
    foreach ($Servers in $serverlist1)
    
    {
    $newfolder = New-Item "\\$serverlist1\C$\Ctest\$folder1\$folder2" -ItemType Dir
    $source = "D:\test\R8\$folder1\$folder2\Products\Manualhandling\IX3" 	
    $destination = $newfolder	
    
    $path = Test-Path $source 			
    If ($path){Copy-Item $source -Destination $destination -Recurse} 
    }
    
    
  • #79088

    Olaf Soyk
    Participant

    If you want to limit the selection of the folder to a specific selection you could provide a list of selectable folders for the user. Then you don't have to check the existence afterwards.

  • #79093

    cosmic
    Participant

    How can I write a script to check again and again that the directory is available or not?

  • #79096

    Olaf Soyk
    Participant

    What do you mean by "available"? Does this question still relate to your initial question?

  • #79097

    cosmic
    Participant
    $folder1 = Read-Host "Enter folder to check"
    $foldername1 = "D:\test\R8\$folder1"
    If (test-path $foldername1) {Write-Host "folder exists on Server." -ForegroundColor Green}
    Else {Write-Host "folder NOT exist on Server." -ForegroundColor Red}

    for example, when I write testfolder to check! If testfolder does not exist I will write again testfolder1 to check! if testfolder1 is not available I will write again!

  • #79106

    Olaf Soyk
    Participant

    Why? How often would you like to check the existence of a folder? If it's not there and you're not gonna create it it does not make much sense to check it again and again and again and again.

    If you wnat to wait for another process to create the folder you can use a loop. A while loop or an do loop

  • #79115

    cosmic
    Participant

    The network path was not found. why ?

    • #79117

      Olaf Soyk
      Participant

      What network path? What are you talking about?

      Is it really that hard to show a little empathy? You get free help here, so I don't think it's too much to ask for a little courtesy to show.

  • #79120

    cosmic
    Participant

    44/5000
    When I run the script, I get the error below!

    Copy-Item : The network path was not found.
    At C:\Users\baa065sa\Powershell skript\kopiering.ps1:35 char:12
    + If ($path){Copy-Item $source -Destination $destination -Recurse}
    +            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (\\server.l...L_8.1.1_09_005P:String) [Copy-Item], I
        + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.CopyItemCommand
    
  • #79123

    cosmic
    Participant
    
    $serverlist1 = Get-Content 'C:\Users\baa065sa\Powershell skript\Levtestservrar2.txt'
    foreach ($Servers in $serverlist1)
    
    {
    
    $newfolder = "\\$serverlist1\C$\Cosmicinst\$folder1\$folder2"
    If (test-path $newfolder) {Write-Host "Katalogen finns redan i IX3 LEVTEST." -ForegroundColor yellow
    exit
    }
    else{
    $source = "D:\CosmicInst\R8\$folder1\$folder2\Products\Manualhandling\IX3" 	
    $destination = $newfolder	
    
    $path = Test-Path $source 			
    If ($path){Copy-Item $source -Destination $destination -Recurse} 
  • #79127

    Max Kozlov
    Participant

    you need to have all of your $destination folder tree exists for Copy-Item to work
    "\\$serverlist1\C$\Cosmicinst\$folder1\$folder2"
    "\\$serverlist1\C$\Cosmicinst\$folder1"
    "\\$serverlist1\C$\Cosmicinst"

    somewhere you doesnt have it
    you can add -Verbose or Write-Host to check

    and change exit to continue

  • #79142

    Kevyn
    Participant

    Cosmic. Hopefully, I correctly understand what you're trying to do.

    What I think you're trying to do.
    1. You have a folder called IX3 located under a path on the source server that has two folder names that can change (Represented in the full directory path below by the variables $Folder1 & $Folder2).

    Full Source Path: D:\CosmicInst\R8\$Folder1\$Folder2\Products\Manualhandling\IX3

    2. If the folder IX3 exists under the above source path, on the source server, you want to check to see if the below full destination path exists. If it does, don't do anything other than write a message to the screen letting you know that it already exists on the server. Again, the $Folder1 & $Folder2 variables can change.

    Full Destination Path: \\$Server\C$\Cosmicinst\$Folder1\$Folder2

    3. If the full source path exists, but the full destination path doesn't, then you want to copy the IX3 folder, and all of the contents under it's structure, to the destination path.

    Full Destination Path (After the copy has been done): \\$Server\C$\Cosmicinst\$Folder1\$Folder2\IX3\RestOfTheCopiedFolderStructure

    If my understanding is correct, the following should work. I haven't tested it and you can always dress it up with error capturing, etc...

    Note: As an FYI, it's a good idea to properly format your code so that it's more readable to people. That way it's easier to understand what you're trying to do, where the issues might be, etc... Also, it's helpful to have a detailed description of what you're trying to do (with full examples) or what your issue is.

    $RootSourcePath = "D:\CosmicInst\R8\"
    $Folder1 = Read-Host "Enter folder name under $RootSourceFolder that you want to look for."
    $Folder2 = Read-Host "Enter the sub-folder name under $RootSourceFolder\$Folder1 that you want to look for."
    $Source = "$RootSourcePath\$Folder1\$Folder2\Products\Manualhandling\IX3" 
    
    If(Test-Path $Source)
    {
      $ServerList = Get-Content 'C:\Users\baa065sa\Powershell skript\Levtestservrar2.txt'
    
      ForEach ($Server in $ServerList)
      {
        $RootDestinationPath = "\\$Server\C$\Cosmicinst\"
        $Destination = "$RootDestinationFolder\$Folder1\$Folder2"
    
        If (Test-Path $Destination)
        {
          Write-Host "Katalogen finns redan i IX3 LEVTEST." -ForegroundColor yellow
          Exit
        }
        Else
        {
          If (!(Test-Path "$RootDestinationPath\$Folder1"))
          {
            #If the parent folder of $Folder2 (i.e. $Folder1) doesn't exist under $RootDestinationPath, create it.
            New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
          }
          #Since the test of the $Destination path failed, we know the $Folder2 folder also doesn't exist, so create it under $RootDestinationPath\$Folder1.
          New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemType Directory
        }
    
        Copy-Item -Path $Source -Destination $Destination -Recurse
      }
    }
    
  • #79229

    cosmic
    Participant

    I getting this error.

    New-Item : The network path was not found.
    At C:\Users\baa065sa\Powershell skript\best.ps1:60 char:9
    +         New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (\\\C$\Cosmicinst\LUL_8.1.1_09:String) [New-Item], IOExce
        + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand
    
    New-Item : The network path was not found.
    At C:\Users\baa065sa\Powershell skript\best.ps1:66 char:7
    +       New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemType Di ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (\\\C$\Cosmicins...L_8.1.1_09_005p:String) [New-Item], IO
        + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand
    
    Copy-Item : The network path was not found.
    At C:\Users\baa065sa\Powershell skript\best.ps1:72 char:7
    +       Copy-Item -Path $Source -Destination $Destination -Recurse
    +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (\\\C$\Cosmicins...L_8.1.1_09_005p:String) [Copy-Item], I
        + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.CopyItemCommand
  • #79267

    Kevyn
    Participant

    Looks like I had some types in my code where I used a variable called $RootSourceFolder, instead of $RootSourcePath, and the same on like 13 of my above code where I used $DestinationRootFolder, instead of $DestinationRootPath, like the rest of my code was using. I've made the corrections below. If the below code fixes don't help, then I would check if the path of \\$Server\C$\Cosmicinst\ exists because I wrote the code (creating $Folder1 & $Folder2) assuming that it does, based on what you told us.

    $RootSourcePath = "D:\CosmicInst\R8\"
    $Folder1 = Read-Host "Enter folder name under $RootSourcePath that you want to look for."
    $Folder2 = Read-Host "Enter the sub-folder name under $RootSourcePath\$Folder1 that you want to look for."
    $Source = "$RootSourcePath\$Folder1\$Folder2\Products\Manualhandling\IX3" 
    
    If(Test-Path $Source)
    {
      $ServerList = Get-Content 'C:\Users\baa065sa\Powershell skript\Levtestservrar2.txt'
    
      ForEach ($Server in $ServerList)
      {
        $RootDestinationPath = "\\$Server\C$\Cosmicinst\"
        $Destination = "$RootDestinationPath\$Folder1\$Folder2"
    
        If (Test-Path $Destination)
        {
          Write-Host "Katalogen finns redan i IX3 LEVTEST." -ForegroundColor yellow
          Exit
        }
        Else
        {
          If (!(Test-Path "$RootDestinationPath\$Folder1"))
          {
            #If the parent folder of $Folder2 (i.e. $Folder1) doesn't exist under $RootDestinationPath, create it.
            New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
          }
          #Since the test of the $Destination path failed, we know the $Folder2 folder also doesn't exist, so create it under $RootDestinationPath\$Folder1.
          New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemType Directory
        }
    
        Copy-Item -Path $Source -Destination $Destination -Recurse
      }
    }
    
  • #79388

    cosmic
    Participant
    PS C:\Users\baa065sa\Powershell skript> .\best.ps1
    Enter folder name under D:\CosmicInst\R8\ that you want to look for.: LUL_8.1.1_09
    Katalogen finns i Server.
    Enter the sub-folder name under D:\CosmicInst\R8\\LUL_8.1.1_09 that you want to look for.: LUL_8.1.1_09_005P
    Katalogen finns i Server.
    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\best.ps1:40 char:9
    +     If (Test-Path $Destination)
    +         ~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\cos-tesr-server.l...L_8.1.1_09_005P:String) [Test-Path], ArgumentExcepti
       on
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand
    
    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\best.ps1:54 char:14
    +        If (!(Test-Path "$RootDestinationPath\$Folder1"))
    +              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\cos-test-server.l...t\\LUL_8.1.1_09:String) [Test-Path], ArgumentExcepti
       on
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand
    
    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\best.ps1:60 char:9
    +         New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\cos-test-server.l...st\LUL_8.1.1_09:String) [New-Item], ArgumentExceptio
       n
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand
    
    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\best.ps1:66 char:7
    +       New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemType Di ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\cos-test-server.l...L_8.1.1_09_005P:String) [New-Item], ArgumentExceptio
       n
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand
    
    Copy-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\best.ps1:72 char:7
    +       Copy-Item -Path $Source -Destination $Destination -Recurse
    +       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Copy-Item], ArgumentException
        + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand
    
    Katalogen finns redan i IX3 cos-tstx-15.lul.se .
  • #79391

    cosmic
    Participant

    I'm running this script

    $RootSourcePath = "D:\CosmicInst\R8\"
    
    
    $Folder1 = Read-Host "Enter folder name under $RootSourcePath that you want to look for."
    
    If (test-path $RootSourcePath\$folder1) {Write-Host "Katalogen finns i Server." -ForegroundColor Green}
    Else {Write-Host "Katalogen INTE finns i Server." -ForegroundColor Red 
    exit
    }
    
    $Folder2 = Read-Host "Enter the sub-folder name under $RootSourcePath\$folder1 that you want to look for."
    
    If (test-path $RootSourcePath\$Folder1\$folder2) {Write-Host "Katalogen finns i Server." -ForegroundColor Green}
    Else {Write-Host "Katalogen INTE finns i Server." -ForegroundColor Red 
    exit
    }
    
    
    $Source = "$RootSourcePath\$Folder1\$Folder2\Products\Manualhandling\IX3"
    
    
    
    If(Test-Path $Source)
    
    {
      
     $ServerList = Get-Content 'C:\Users\baa065sa\Powershell skript\Levtestservrar.txt'
    
      ForEach ($Server in $ServerList)
      
    
     {
        
        $RootDestinationPath = "\\$Server\C$\Cosmicinst\"
    
        $Destination = "$RootDestinationPath\$Folder1\$Folder2"
    
    
    
        If (Test-Path $Destination)
    
         {
          
          Write-Host "Katalogen finns redan i IX3 $server ." -ForegroundColor yellow
          
          Exit
        
         }
        
         Else
        
          {
          
           If (!(Test-Path "$RootDestinationPath\$Folder1"))
          
           {
            
             #If the parent folder of $Folder2 (i.e. $Folder1) doesn't exist under $RootDestinationPath, create it.
     
            New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
          
           }
    
          #Since the test of the $Destination path failed, we know the $Folder2 folder also doesn't exist, so create it under $RootDestinationPath\$Folder1.
    
          New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemType Directory
        
          }
    
        
    
          Copy-Item -Path $Source -Destination $Destination -Recurse
      
         }
    
    }
  • #79439

    Kevyn
    Participant

    1. First of all, change the $RootSourcePath & $DestinationSourcePath as below(i.e. take the backslash (\) off the end to get rid of the double-backslash (\\) you're seeing in the $Source & $Destination variables). This isn't the problem, but it'll make the path look better.

    $RootSourcePath = "D:\CosmicInst\R8"
    $RootDestinationPath = "\\$Server\C$\Cosmicinst"
    

    My suggested code updated.

    $RootSourcePath = "D:\CosmicInst\R8"
    $Folder1 = Read-Host "Enter folder name under $RootSourcePath that you want to look for."
    $Folder2 = Read-Host "Enter the sub-folder name under $RootSourcePath\$Folder1 that you want to look for."
    $Source = "$RootSourcePath\$Folder1\$Folder2\Products\Manualhandling\IX3" 
    
    If(Test-Path $Source)
    {
      $ServerList = Get-Content 'C:\Users\baa065sa\Powershell skript\Levtestservrar2.txt'
    
      ForEach ($Server in $ServerList)
      {
        $RootDestinationPath = "\\$Server\C$\Cosmicinst"
        $Destination = "$RootDestinationPath\$Folder1\$Folder2"
    
        If (Test-Path $Destination)
        {
          Write-Host "Katalogen finns redan i IX3 LEVTEST." -ForegroundColor yellow
          Exit
        }
        Else
        {
          If (!(Test-Path "$RootDestinationPath\$Folder1"))
          {
            #If the parent folder of $Folder2 (i.e. $Folder1) doesn't exist under $RootDestinationPath, create it.
            New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
          }
          #Since the test of the $Destination path failed, we know the $Folder2 folder also doesn't exist, so create it under $RootDestinationPath\$Folder1.
          New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemType Directory
        }
    
        Copy-Item -Path $Source -Destination $Destination -Recurse
      }
    }
    

    2. Why are you testing first for $RootSourcePath\$Folder1 & then for $RootSourcePath\$Folder1\$Folder2? In the code I suggested, I test just for the later path of $RootSourcePath\$Folder1\$Folder2, which is stored in the $Source variable. If $RootSourcePath\$Folder1\$Folder2 (I.e $Source) exists, then so does $RootSourcePath\$Folder1\.

    3. Now for the problem at hand with the "Invalid characters in path" error.

    Unfortunately, the error code doesn't show the complete paths, so it's hard to see what illegal characters there may be. I tried reproducing the issue as best I could with what you posted, but I couldn't reproduce the issue. I would suggest the following:
    1. Try updating the code as I suggested at the top (i.e. taking out the backslashes (\) in the $SourceRootPath & $DestinationRootPath variables).
    2. If that doesn't fix it, you might trying doing a Write-Host of the path in question just before the line where the error occurs and looking to see what illegal characters there may be.

  • #79447

    Kevyn
    Participant

    Looks like you got the answer toe the "Invalid characters in path" error from Don Jones. My eyes glossed right over the "C$" part.

    https://powershell.org/forums/topic/powershell-error/

  • #79480

    cosmic
    Participant

    two new Error!

    Copy-Item : An item with the specified name \\servertest\C$\Cosmicinst\LUL_8.1.1_09\LUL_8.1.1_09_006P\IX3\IX3Ma
    nager\scripts already exists.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:62 char:5
    +     Copy-Item -Path $Source -Destination $Destination -Recurse
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ResourceExists: (\\servertest.l...Manager\scripts:String) [Copy-Item], IOException
        + FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.CopyItemCommand
    Copy-Item : The network path was not found.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:62 char:5
    +     Copy-Item -Path $Source -Destination $Destination -Recurse
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : WriteError: (IX3Manager.exe.config:FileInfo) [Copy-Item], IOException
        + FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
  • #79483

    cosmic
    Participant

    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:28 char:9
    + If (Test-Path $Destination)
    + ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicin...L_8.1.1_09_006P:String) [Test-Path], ArgumentExcep
    ti on
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand

    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:42 char:9
    + If (!(Test-Path "$RootDestinationPath\$Folder1"))
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicinst\LUL_8.1.1_09:String) [Test-Path], ArgumentExceptio
    n
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand

    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:48 char:11
    + New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicinst\LUL_8.1.1_09:String) [New-Item], ArgumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:55 char:13
    + New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicin...L_8.1.1_09_006P:String) [New-Item], ArgumentExcept
    io n
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

    Copy-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:62 char:5
    + Copy-Item -Path $Source -Destination $Destination -Recurse
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Copy-Item], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand

    
    
    		
    	
  • #79486

    cosmic
    Participant
    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:28 char:9
    +     If (Test-Path $Destination)
    +         ~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\    \C$\Cosmicin...L_8.1.1_09_006P:String) [Test-Path], ArgumentExcep
    ti    on
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand
    
    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:42 char:9
    +         If (!(Test-Path "$RootDestinationPath\$Folder1"))
    +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\    \C$\Cosmicinst\LUL_8.1.1_09:String) [Test-Path], ArgumentExceptio
    n
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand
    
    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:48 char:11
    +                 New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\    \C$\Cosmicinst\LUL_8.1.1_09:String) [New-Item], ArgumentException
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand
    
    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:55 char:13
    +             New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (\\    \C$\Cosmicin...L_8.1.1_09_006P:String) [New-Item], ArgumentExcept
    io    n
        + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand
    
    Copy-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:62 char:5
    +     Copy-Item -Path $Source -Destination $Destination -Recurse
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Copy-Item], ArgumentException
        + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand
    
  • #79487

    cosmic
    Participant

    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:28 char:9
    + If (Test-Path $Destination)
    + ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicin...L_8.1.1_09_006P:String) [Test-Path], ArgumentExcep
    ti on
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand

    Test-Path : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:42 char:9
    + If (!(Test-Path "$RootDestinationPath\$Folder1"))
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicinst\LUL_8.1.1_09:String) [Test-Path], ArgumentExceptio
    n
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.TestPathCommand

    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:48 char:11
    + New-Item -Name $Folder1 -Path $RootDestinationPath -ItemType Directory
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicinst\LUL_8.1.1_09:String) [New-Item], ArgumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

    New-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:55 char:13
    + New-Item -Name $Folder2 -Path "$RootDestinationPath\$Folder1" -ItemT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (\\ \C$\Cosmicin...L_8.1.1_09_006P:String) [New-Item], ArgumentExcept
    io n
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.NewItemCommand

    Copy-Item : Illegal characters in path.
    At C:\Users\baa065sa\Powershell skript\sugest.ps1:62 char:5
    + Copy-Item -Path $Source -Destination $Destination -Recurse
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Copy-Item], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand

  • #79610

    Kevyn
    Participant

    For the first error, does that "scripts" directory (C:\Cosmicinst\LUL_8.1.1_09\LUL_8.1.1_09_006P\IX3\IX3Ma
    nager\scripts) exist on Servertest?

    For the second error, I couldn't find much on it. Maybe you'll have better luck. Maybe it will work if you try again? I did some one thing similar, and they didn't see the issue with tools called xcopy and robocopy.

  • #79673

    cosmic
    Participant

    What can I do for the first error! How can I write if the directory is copied again! I do not want to show this erroren!

You must be logged in to reply to this topic.