Powershell Workflows not displaying anything

Trying to work with workflows in powershell but have run into a snag.

Running Powershell 4.0 on Windows 7 I have created sample workflows. When I go and execute them I get a brief "blip" on my screen as if something is happening (looks like a progression bar) but nothing displays. Even the simple hello world script doesn't work.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
when you define a workflow i.e.
workflow helloworld {
"Hello World"

Open in new window

like a function it will be defined but you have to execute it

reference: http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx
RichardPWolfAuthor Commented:
Which I've done. As I said after executing the workflow nothing is displayed.
Hi, I must admit this is the first time I've ever looked at workflows, but I was able to get the sample working by putting the code into TestPS1.ps1, and executing the script.  This loads the workflow into memory, then you can execute the workflow directly:

PS C:\temp\scripts> .\TestPS1.ps1

PS C:\temp\scripts> helloworld
Hello World

PS C:\temp\scripts>

Have you tried that sequence?  The workflow remains available for that Powershell session.  Closing the ISE and opening a new session results in the workflow not being found.

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

David Johnson, CD, MVPOwnerCommented:
http://www.screencast.com/t/9GNVakqFJwk  you can't duplicate this?
RichardPWolfAuthor Commented:
All it does is display the code nothing else.

My results are attached.
Running the code only loads the HelloWorld workflow into memory. You need to execute HelloWorld at the command line after you run the code.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RichardPWolfAuthor Commented:
Ahhh. That I didn't do. Let me try that.
RichardPWolfAuthor Commented:
It works. Yeah. I knew I was doing something wrong. Now I can proceed.

Thank you very much.
RichardPWolfAuthor Commented:
VERY, VERY helpful.
No problem. I may look into workflows one day to study the difference between workflows and Invoke-Command in terms of paralleledness (???) and efficiency.  I'm a newbie to that concept, so at first impressions, I can't see where they differ too greatly.

Thanks for the grade.

RichardPWolfAuthor Commented:
Where I'm looking at using workflows is for my reports that tag about 20 servers. As it stands in a sequential access these reports take about 8+ hours to run. By running in parallel I should be able to dramatically reduce that time. I've tried using the "job" functions of powershell but I've never got them to run.
David Johnson, CD, MVPOwnerCommented:
please read the reference that I gave and look at the parallel item
workflow foreachpsptest {


   foreach –parallel ($computer in $computers){

    sequence {

      Get-WmiObject -Class Win32_ComputerSystem -PSComputerName $computer

      Get-WmiObject –Class Win32_OperatingSystem –PSComputerName $computer

      $disks = Get-WmiObject -Class Win32_LogicalDisk `

         -Filter "DriveType = 3" –PSComputerName $computer


      foreach -parallel ($disk in $disks){

        sequence {

          $vol = Get-WmiObject -Class Win32_Volume `

          -Filter "DriveLetter = '$($disk.DeviceID)'" `

          –PSComputerName $computer

          Invoke-WmiMethod -Path $($vol.__PATH) -Name DefragAnalysis






foreachpstest  -Computers "server01", "server02", "server03"
RichardPWolfAuthor Commented:
Right. I've copied the code to dissect it for my reports. Hope that's alright. This is a long term project as I've got many reports due at the first of the month and I'm trying to script as many as possible (work smarter not harder).

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.