Using powershell ISE,
If I open the file below by clicking on the .ps1 file in windows explorer, when I run it with the green arrow, it works. If use File->Open the same file, when i click the green arrow I get errors.
If i open it by clicking and then load it, it's fine, so something (the path?) is getting set when i double click that is not the other way...
Let me clarify... If I open the file one way(double click) it 'compiles' fine, if I open it the other way (file->Open) the exact same file does not 'compile'. I'm hoping to figure out why this is. My guess is that the path variable it uses to find the other files needed is set different via the two methods of opening (because many of the errors are 'not found')
here is the code of the file (it basically just calls a bunch of external stuff)
###########################################################
# RUN (hit the green arrow) TO INITIALIZE
############################################################
############################################################
# set defaults
$path = Get-Location
$ProjectName = $path.Path
$ProjectName = $ProjectName.Replace("D:\Project Files\", "")
$ProjectName = $ProjectName.Replace("\_Powershell", "")
$ProjectName = $ProjectName.Replace("\WebApp", "")
$ProjectName = $ProjectName.Replace("\Webapp", "")
write-host "Project Name found: " $ProjectName
$Project = $ProjectName
$RootPath = 'D:\Project Files\' + $Project + '\WebApp'
$ModulePath = 'D:\Project Files\' + $Project + '\WebApp\_PowerShell'
############################################################
# call this one to remove and reload the modules (if modules are modified)
function ReloadTemplates {
RemoveLoadedModule WPK
RemoveLoadedModule JcdcAddFileToProjectGui
RemoveLoadedModule JcdcEoAndMap
RemoveLoadedModule JcdcEoAndMapGui
RemoveLoadedModule JcdcDal
RemoveLoadedModule JcdcDalGui
RemoveLoadedModule JcdcBll
RemoveLoadedModule JcdcBLLGui
RemoveLoadedModule JcdcView
RemoveLoadedModule JcdcViewGui
RemoveLoadedModule JcdcController
RemoveLoadedModule JcdcControllerGui
RemoveLoadedModule JcdcAutoMap
RemoveLoadedModule JcdcAutoMapGui
RemoveLoadedModule JcdcReport
RemoveLoadedModule JcdcReportGui
RemoveLoadedModule JcdcCv
RemoveLoadedModule JcdcCvGui
RemoveLoadedModule ReadWriteXML
# load the Templates
LoadTemplates
}
function RemoveLoadedModule {
param($PathAndName)
if(Get-Module -name $PathAndName)
{
Remove-Module $PathAndName
}
}
############################################################
# call this one to load the modules
function LoadTemplates {
Import-Module WPK
Import-Module "$ModulePath\JcdcAddFileToProjectGui.psm1"
Import-Module "$ModulePath\JcdcEoAndMap.psm1"
Import-Module "$ModulePath\JcdcEoAndMapGui.psm1"
Import-Module "$ModulePath\JcdcDal.psm1"
Import-Module "$ModulePath\JcdcDalGui.psm1"
Import-Module "$ModulePath\JcdcBll.psm1"
Import-Module "$ModulePath\JcdcBLLGui.psm1"
Import-Module "$ModulePath\JcdcView.psm1"
Import-Module "$ModulePath\JcdcViewGui.psm1"
Import-Module "$ModulePath\JcdcController.psm1"
Import-Module "$ModulePath\JcdcControllerGui.psm1"
Import-Module "$ModulePath\JcdcAutoMap.psm1"
Import-Module "$ModulePath\JcdcAutoMapGui.psm1"
Import-Module "$ModulePath\JcdcReport.psm1"
Import-Module "$ModulePath\JcdcReportGui.psm1"
Import-Module "$ModulePath\JcdcCv.psm1"
Import-Module "$ModulePath\JcdcCvGui.psm1"
Import-Module "$ModulePath\ReadWriteXML.psm1"
Initialize-AddFileToProject $RootPath $Project
Initialize-EOMAPGui $RootPath $Project
Initialize-DALGui $RootPath $Project
Initialize-BLLGui $RootPath $Project
Initialize-ViewGui $RootPath $Project
Initialize-ControllerGui $RootPath $Project
Initialize-AutoMapGui $RootPath $Project
Initialize-ReportGui $RootPath $Project
Initialize-CVGui $RootPath $Project
Initialize-XMLArguments
}
############################################################
# load the Templates on Run (when green arrow is clicked)
ReloadTemplates
#
Type one of the following in the command window
Select-A + = Select-AddFileToProject -To create file to add to project
Select-B + = Select-BLLWhatToBuild -To add a BLL
Select-C + = Select-ControllerWhatToBuild -To add a Controller
Select-D + = Select-DALWhatToBuild -To add a DAL
Select-E + = Select-EoAndMapBuild -To add a Eo and Map
Select-M + = Select-MapBuild -To add a AutoMap
Select-R + = Select-ReportWhatToBuild -To add a Report
Select-Vi + = Select-ViewWhatToBuild -To add a View
Select-Vm + = Select-VmCvOrExcel -To add a CV, VM, D:\PowerShellTemplatesArgsor Excel
Here are the errors
PS U:> D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1 Project Name found: U:\ Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcAddFileToProjectGui.psm1' was not loaded because no valid module file was found in any module direc tory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:61 char:18 + Import-Module <<<< "$ModulePath\JcdcAddFileToProjectGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...ProjectGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcEoAndMap.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:62 char:18 + Import-Module <<<< "$ModulePath\JcdcEoAndMap.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...dcEoAndMap.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcEoAndMapGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:63 char:18 + Import-Module <<<< "$ModulePath\JcdcEoAndMapGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...oAndMapGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcDal.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:64 char:18 + Import-Module <<<< "$ModulePath\JcdcDal.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...ll\JcdcDal.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcDalGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:65 char:18 + Import-Module <<<< "$ModulePath\JcdcDalGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...JcdcDalGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcBll.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:66 char:18 + Import-Module <<<< "$ModulePath\JcdcBll.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...ll\JcdcBll.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcBLLGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:67 char:18 + Import-Module <<<< "$ModulePath\JcdcBLLGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...JcdcBLLGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcView.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:68 char:18 + Import-Module <<<< "$ModulePath\JcdcView.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...l\JcdcView.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcViewGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:69 char:18 + Import-Module <<<< "$ModulePath\JcdcViewGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...cdcViewGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcController.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:70 char:18 + Import-Module <<<< "$ModulePath\JcdcController.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...Controller.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcControllerGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:71 char:18 + Import-Module <<<< "$ModulePath\JcdcControllerGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...trollerGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcAutoMap.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:72 char:18 + Import-Module <<<< "$ModulePath\JcdcAutoMap.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...cdcAutoMap.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcAutoMapGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:73 char:18 + Import-Module <<<< "$ModulePath\JcdcAutoMapGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...AutoMapGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcReport.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:74 char:18 + Import-Module <<<< "$ModulePath\JcdcReport.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...JcdcReport.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcReportGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:75 char:18 + Import-Module <<<< "$ModulePath\JcdcReportGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...cReportGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcCv.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:76 char:18 + Import-Module <<<< "$ModulePath\JcdcCv.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...ell\JcdcCv.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\JcdcCvGui.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:77 char:18 + Import-Module <<<< "$ModulePath\JcdcCvGui.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...\JcdcCvGui.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module 'D:\Project Files\U:\WebApp_PowerShell\ReadWriteXML.psm1' was not loaded because no valid module file was found in any module directory. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:78 char:18 + Import-Module <<<< "$ModulePath\ReadWriteXML.psm1" + CategoryInfo : ResourceUnavailable: (D:\Project File...adWriteXML.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
The term 'Initialize-AddFileToProject' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was includ ed, verify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:80 char:29 + Initialize-AddFileToProject <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-AddFileToProject:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-EOMAPGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, veri fy that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:81 char:24 + Initialize-EOMAPGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-EOMAPGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-DALGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:82 char:22 + Initialize-DALGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-DALGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-BLLGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:83 char:22 + Initialize-BLLGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-BLLGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-ViewGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verif y that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:84 char:23 + Initialize-ViewGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-ViewGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-ControllerGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:85 char:29 + Initialize-ControllerGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-ControllerGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-AutoMapGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, ve rify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:86 char:26 + Initialize-AutoMapGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-AutoMapGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-ReportGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, ver ify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:87 char:25 + Initialize-ReportGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-ReportGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-CVGui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:88 char:21 + Initialize-CVGui <<<< $RootPath $Project + CategoryInfo : ObjectNotFound: (Initialize-CVGui:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
The term 'Initialize-XMLArguments' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\Project Files\CIS3G\Webapp_Powershell\ManualRun.ps1:89 char:28 + Initialize-XMLArguments <<<< + CategoryInfo : ObjectNotFound: (Initialize-XMLArguments:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Is there some way to set the path when I do a file open so this does not occur?
There are different versions of this folder and file for each project, as it's used to generate project specific code... so teh soloution needs to work for that scenerio too please.
Any help is greatly appreicated.