Page 2 of 2

Re: Scripting Question

Posted: Wed Oct 03, 2018 1:56 pm
by jvierra
The best I can do is this:

Code: Select all

$buttonBrowseFolder_Click = {
    if ($folderbrowserdialog2.ShowDialog() -eq 'OK'){
        $textboxFolder.Text = $folderbrowserdialog2.SelectedPath
        $Back_Rec_Path = $folderbrowserdialog2.SelectedPath
        Update-ListBox $ListBox1 "create Backup Directory / read Backup Directory" -Append
        $global:DestPath = []::Combine($Back_Rec_Path,'BACKUP', $Env:USERNAME)
        Update-ListBox $ListBox1 "create Log Folder / read Log Folder" -Append
        $global:DestPathLog = $DestPath + "\!LOG" # 
        $global:LogFile = $DestPathLog + "\Robocopy_Profil_copy.txt"

        If (!(test-path $DestpathLog)){ #sollte das Zielverzeichnis nicht vorhanden sein, läuft Robocopy wegen der LOG-Datei in einen Fehler...
            New-Item -ItemType Directory -Force -Path $DestpathLog
I recommend running your code with the debugger to verify that you are getting the correct values. I see no way with this minimal example to determine what is causing your issue.

If "Test-Path" fails you are doing nothing. You need to do something when the path does not exist.

Re: Scripting Question

Posted: Thu Oct 04, 2018 2:57 am
by boskap
ok but why it works with powershell v5
it creates the folder when it not exists

it only should create the folde if it not exists

Re: Scripting Question

Posted: Thu Oct 04, 2018 3:22 am
by jvierra
Please run in debugger to find your issue. We cannot see tour system.