Donnerstag, 3. Juli 2014

Two workarounds to the PowerShell Workflow Problem

I got two workarounds to the problem in previous post.

Frank Peter Schultze ‏@fpschultze proposed to use inlinescript

 Workflow Strange
{
    param(
        [string]$folder
        )

    inlinescript
    {
    !(Test-Path -path $using:folder)
    }
}

and I found the following solution

Workflow Strange
{
    param(
        [string]$folder
        )
    $a = Test-Path -path $folder
    ! $a
}

Test-Path in PowerShell Workflow Problem

Hello PowerShell World.
I'm back an my current focus is PowerShell WorkFlows.

And I just found a strange example I can't explain.

Workflow Strange
{
    param(
        [string]$folder
        )


    if (Test-Path -path $folder)
    {
        "Folder $folder exists"
    }
    if (!(Test-Path -path $folder))
    {
        "Folder $folder seenms not exists"
        "But Get-Item shows it is there"
        Get-item -path $folder

    }

    $a = (Test-Path -path $folder)
    ! $a
}

Strange -folder 'C:\temp' -PSComputerName  MAGV-2012AKTDE
And here is its output

Folder C:\temp exists
Folder C:\temp seenms not exists
But Get-Item shows it is there


    Verzeichnis: C:\


Mode                LastWriteTime     Length Name                                                                          PSComputerName                                                             
----                -------------     ------ ----                                                                          --------------                                                             
d----        22.08.2013     10:53            temp                                                                          MAGV-2012AKTDE                                                             
True






All involved machines running PowerShell V3.0.