Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync PowerShell Workflow runbook with foreach -parallel function give error #16573

Closed
erikverwer opened this issue Oct 10, 2018 — with docs.microsoft.com · 16 comments
Closed

Comments

Copy link

Failed to sync.
File parsing error:

  • Assert-AutoShutdownSchedule.ps1

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@femsulu
Copy link
Member

femsulu commented Oct 10, 2018

@erikverwer Thanks for the Comment. We are actively investigating and will get back to you soon.

@femsulu femsulu self-assigned this Oct 11, 2018
@georgewallace
Copy link
Contributor

@erikverwer I just tested syncing a PowerShell Workflow runbook using the TFSV source control type with a foreach -parallel and everything synced correctly. Can you provide the example runbook content? I know there is a community solution with the same runbook name but it doesn't use workflow.

@erikverwer
Copy link
Author

@georgewallace Thanks for testing. I’ve changed the script to a workflow so that we can do the jobs in parallel. I also test it with a new script with the following content which also failed to sync.
workflow test-workflow {
$Array = @("Value1", "Value2")

Foreach -parallel ($Item in $Array) {
    $Item
}

}

sync-error

@georgewallace
Copy link
Contributor

@erikverwer Thanks for this additional information let me try a couple other times to repro.

@georgewallace
Copy link
Contributor

@erikverwer I tried with VSTS Git source control type as well and it was successful, now I just put the small workflow logic you have above in my workflow and it worked. If you just put the following code in your source control repo and try to sync does it still fail?

workflow Test-Workflow {
$Array = @("Value1", "Value2")
Foreach -parallel ($Item in $Array) {
    $Item
}
}

image

@erikverwer
Copy link
Author

yes even with that sample code it will fail. and when i remove -parallel the sync is working.
image

@erikverwer
Copy link
Author

Hmm, syncing is not consistent. at first i thougt it was because my project contains subfolders with spaces in the name. but when i put the scripts in the root or in folders without spaces it works sometimes.

@georgewallace
Copy link
Contributor

georgewallace commented Oct 17, 2018

@erikverwer Can you share an actual copy of the script? If you don't want to add it in the issue comments you can email it to me and first.last@microsoft.com. Also additional questions, do you have the latest Azure modules, can you manually import the runbook using Import-AzureRmAutomationRunbook?

@erikverwer
Copy link
Author

Newly created VSTS Git Project and newly created Automation Account give the same result.
workflow test-workflow { $Array = @("Value1", "Value2", "Value3") Foreach -parallel ($Item in $Array) { $Item } }
image

manual import works fine.
image
image
image

Now updating the modules... keep you updated.

@erikverwer
Copy link
Author

after updating the modules still the same result.
image
image

@erikverwer
Copy link
Author

erikverwer commented Oct 17, 2018

added a copy and removed -parallel and that one is synced. but not as workflow runbook. I see now and with strange characters in the script.
image
image
image
workflow test-workflow { $Array = @("Value1", "Value2", "Value3") Foreach ($Item in $Array) { $Item } }

@erikverwer
Copy link
Author

my test scripts in a zip file
SourceControl.zip

@femsulu
Copy link
Member

femsulu commented Oct 19, 2018

@erikverwer - I hate to break the momentum here but this channel is reserved for doc comment engagements. your issue will be better served as a support, Forum or an offline/email engagement. Please send mail to Azcommunity@microsoft.com with pertinent issue details including your subscription ID and we can continue the investigation.

@georgewallace - FYI.

@femsulu femsulu closed this as completed Oct 19, 2018
@femsulu femsulu added the forum label Oct 19, 2018
@jefshe
Copy link

jefshe commented Nov 13, 2018

I had this exact same issue.

Since this is the top result for me when I search for this error, it turns out i had a unicode hyphen in my script which the parser didn't like. It would be nice to have a proper error message for this case

Copy link

I am not if this a stupid question.
Let's say I have a .ps1 script file in my VSTS Repo and when I Sync it, I am able to see the script file reflecting in my runbook but let's say...

My Repo is having a module folder with .psm1 & .psd1 and other stuff then the same is not displaying under the modules after Sync. Where can expect the reaction? or how can I sync my modules?

Copy link

  1. unknown characters get added to the runbook after sync from the source control when the PowerShell source file is not ASCII encoded.
  2. As of today, the source control works only for RunBooks but not capable to handle the module files (.psm1 or .psd1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants