Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Error MethodNotFound in PowerShell script

Hello,

I'm getting an error with the PowerShell scripts not reading the MinDate correctly.
*** Error. Min date in psconfig file is but should be between 1960-01-01 and 2050-01-01

Method Invocation failed because [System.Object[]] doesn't contain a method named 'IndexOf'
$minDate = ($config | Select-Object -Index(($config.IndexOf <<<< ("<MinDate>"))+1)).Replace("<.MinDate>","");

I copied my data from WebWork 2.0 Migration to the psConfig.txt .file and changed the PSData folder to "..\PSData\"

# MinDate: Minimum date for Portfolio Slicer.

2010-12-31


I also tried it renaming the PSConfig-Demo.txt file to psConfig.txt and got the same error.

I'm running under Windows 7.
PowerShell PSVersion 2.0 BuildVersion 6.1.7601.17514.

Thank you for all your hard work!
Traci

Comments

  • Hi Traci,

    Sorry about your problems.
    Could we do tests on your machine?
    1. In "Scripts" subfolder create new file "test1.ps1".
    2. Click edit - "Windows PowerShell ISE" will start. Add following code to this file:

    cls;
    $PSVersionTable.PSVersion;"";"";"";
    $scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition; $scriptPathParent = Split-Path -path $scriptPath -Parent;
    $configFile = $scriptPath + "\psConfig.txt"; if (!(Test-Path -Path $configFile)) {"Config file not found: $configFile"; exit(1)};
    $config = gc $configFile | ? {$_.trim() -ne "" -and !$_.StartsWith("#") }; # Getting config file without empty lines and comments
    $minDate = ($config | Select-Object -Index(($config.IndexOf(""))+1)).Replace("","");
    $minDate;
    "";"";
    $config



    3. Execute this file. What is the output? Can you share it here?
  • Thank you for the quick response! I tried upgrading to Powershell 3.0 and that solved the problem.

    Here is the link to Windows Management Framework 3.0 if anyone else has this issue.
    https://www.microsoft.com/en-us/download/details.aspx?id=34595
  • Great, thanks for letting us know! I'll add link to documentation about this!
Sign In or Register to comment.