Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1090521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:23:10+00:00 2026-05-16T23:23:10+00:00

Working through Jerry Lee Ford Jr.’s Powershell 2.0 for the Absolute Beginner book. There’s

  • 0

Working through Jerry Lee Ford Jr.’s Powershell 2.0 for the Absolute Beginner book. There’s a lot of typographical errors in the code of the book that I’ve been able to work through and correct (great practice), but there’s one I simply can’t seem to figure out. Downloaded his stock code from the companion website, and his code is throwing the exact same error. Code is as follows:

# *************************************************************************
#
# Script Name: GameConsole.ps1 (The PowerShell Game Console)
# Version:     1.0
# Author:      Jerry Lee Ford, Jr.
# Date:        January 1, 2007
# 
# Description: This PowerShell script provides a listing of PowerShell
#              game scripts and allows the player to play any game by 
#              entering its menu number.
# 
# *************************************************************************


# Initialization Section

$menuList = @()  #Stores an array containing information about script games
$playAgain = "True"  #Controls the execution of a loop that controls game
                     #execution

# Functions and Filters Section

#This function gets the player's permission to begin the game
function Get-GameListing {

  $gameList = @()  #Stores and array containing a list of PowerShell scripts
  $i = 0  #Used to set the index value of the array when adding elements to it

  Clear-Host  #Clear the screen
  Write-Host  #Display a game console header
  Write-Host " --------------------------------------------------------------"
  Write-Host " Windows PowerShell Game Console" -foregroundColor darkred
  Write-Host " --------------------------------------------------------------"

  $location = Set-Location C:\ShellScripts\Games  #Specify the location of the game scripts

  #Load an array with a list of all the PowerShell scripts in the specified folder
  $gameList = Get-ChildItem . *.ps1  # | ForEach-Object -process {$i++; $gameList[$i] = $_.Name }
  $gameList  #Return the contents of the array to the calling statement

}

#This function displays a menu listing of PowerShell games
function Write-MenuList {

  param($list)  #The list of games to be displayed is passed as an array
  $Counter = 0  #Used to number each menu item

  Write-Host ""

  ForEach ($i in $list) {  #Iterate for each script stored in the array

    $counter++  #Increment the counter by 1

    if ($counter -lt 10) {  #Format the display of the first 9 scripts
      Write-Host " $counter.  $i" -foregroundColor blue
    }
    else {  #Format the display of all remaining scripts
      Write-Host " $counter. $i" -foregroundColor blue
    }

  }

  Write-Host "`n --------------------------------------------------------------"

}

function End-ScriptExecution {

  Clear-Host #Clear the screen

  Write-Host "`n Thank you for using the Windows PowerShell Game Console"

  Start-Sleep 3  #Pause the execution of the script for 3 seconds

  Clear-Host  #Clear the screen

}


# Main Processing Section

$response = 0  #Stores player input

#Continue playing new games until the player decides to close the game console
while ($playAgain -eq "True") {

  #Call the function that generates an array containing a list of game scripts
  $menuList = Get-GameListing  

  #Call function that converts the contents of the array into a list of menu items
  Write-MenuList $menuList

  #Prompt the player to pick a game to play
  $response = Read-Host "`n Enter the menu number for a game or Q to quit"

  #Prepare to close the game console when the user decides to quit
  if ($response -eq "Q") {
    $playAgain = "False"  #Modify variable value in order to terminate the loop
    continue  #Repeat the loop
  }

  #Convert the player's input to a integer and then validate the player's input
  if ([int]$response -lt 1) {  #Anything below 1 is not a valid menu number
    Clear-Host  #Clear the screen
    Write-Host "`n `a`aInvalid selection."
    Read-Host   #Pause the script until the player presses the Enter key
    continue    #Repeat the loop
  }

  if ([int]$response -gt $menuList.length) {
    Clear-Host  #Clear the screen
    Write-Host "`n `a`aInvalid selection."
    Read-Host   #Pause the script until the player presses the Enter key
    continue    #Repeat the loop
  }

  Invoke-Expression $menuList[$response]  #Executed the selected game script

  Clear-Host  #Clear the screen

}

End-ScriptExecution

The error being thrown is:

The term 'fortuneteller.ps1' is not recognized as the name of a cmdlet, functio
n, script file, or operable program. Check the spelling of the name, or if a pa
th was included, verify that the path is correct and try again.
At line:1 char:18
+ fortuneteller.ps1 <<<< 
    + CategoryInfo          : ObjectNotFound: (fortuneteller.ps1:String) [], C 
   ommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

No matter what ps script menu item I choose, I’m getting the same error. Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:23:11+00:00Added an answer on May 16, 2026 at 11:23 pm

    Modify this line:

    Invoke-Expression $menuList[$response]  #Executed the selected game script 
    

    to:

    Invoke-Expression $menuList[$response].FullName
    

    or my preference:

    & $menuList[$response].FullName
    

    It was failing most likely because it is trying to execute “FortuneTeller.ps1” and the working directory is either not in that dir or even if it is in that dir, PowerShell will not execute a script from the current dir without specifying the path e.g. “.\FortuneTeller.ps1”. By specifying the full path via the FullName property this problem is avoided.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working through Pro ASP.NET MVC book and I got the following code snippet that
Working through more book examples- this one is a partial poker program- This segment
Working through the WROX Beginning ASP.NET MVC 1.0 book I've hit a strange 'error'.
Working through a sample in Chapter 3 of Programming in Scala, the following code
I've been working through a fantastic book (Pro ASP.net MVC 2 Framework, Steven Sanderson)
I've been working through Practical Common Lisp and as an exercise decided to write
I'm working through previous years ACM Programming Competition problems trying to get better at
I'm currently working through an assignment that deals with Big-O and running times. I
I've been working through a recent Computer Science homework involving recursion and big-O notation.
I'm working through Practical Web 2.0 Appications currently and have hit a bit of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.