# problem in my program, get fault

**URL:** <https://forums.powershell.org/t/problem-in-my-program-get-fault/15136>\
**Category:** PowerShell Help\
**Created:** [October 23, 2020, 6:07am UTC](https://forums.powershell.org/t/problem-in-my-program-get-fault/15136 "2020-10-23T06:07:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tepke](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@tepke](https://forums.powershell.org/u/tepke)\
**Post date:** [October 23, 2020, 6:07am UTC](https://forums.powershell.org/t/problem-in-my-program-get-fault/15136/1 "2020-10-23T06:07:33Z")

</div>

```
if($file -match '^(I[A-Z]\d{6}_' | Foreach { $Matches[0] })
    
    {
```

Hi we have a ERP system that looks into a map where are shortcuts to documents. the map of documents is now to big a lot of documents. I want to copy some documents to a higher map 2018. and i want to restore the shortcuts. my orders are beginning with a I and then a letter. i get a fout in the position above

\<!–more–\>

```
## Hugo Maris VDL Industrial Products
## 11-2018
echo "------Logistix Data Robot By Hugo Maris------"

#Locatie's

$plotlocation ="C:\test\2018\";
$shortcutlocation= "C:\test\dosyslog\";

function CreateShortcut {
    Param($sourcefile, $destenationpath)
    
    echo "--CreateShortcut()--";
    $shortcutpath = $destenationpath + ".lnk";
    
    if (!(Test-Path $shortcutpath)) {
        echo "s> s> $sourcefile"; 
        echo "s> d> $shortcutpath"; 
          
        $Shell = New-Object -ComObject ("WScript.Shell");
        $ShortCut = $Shell.CreateShortcut($shortcutpath);
        $ShortCut.TargetPath=$sourcefile;
        $ShortCut.Save();
    }
    
  
    echo "--!CreateShortcut()--";
}

 Get-ChildItem $plotlocation   
 Foreach-Object { 
 
    $file = $_.Name.toupper()
  
    if($file -match '^(I[A-Z]\d{6}_' | Foreach { $Matches[0] })
    
    {   
        $folder = "VerkoopOrder\document\";
    
        $logistixId = $Matches[0]
        echo "Move to artikel $logistixId"  
        echo $file
        $filelocation = $_.FullName;
        $destenationpath = $shortcutlocation + $folder + $logistixId + $file;
        
        echo $filelocation
        echo $shortcutlocation

        CreateShortcut $filelocation $destenationpath ;
    }
   
}

echo "-------------Einde script-------------";
```

&nbsp;

\<!–more–\>

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/problem-in-my-program-get-fault/15136/2 "2024-05-16T20:28:40Z")

</div>


