- Aug
- 2,015
- 81
Invoking julian.ps1 with PowerShell works, but invoking with PSHELL gives an error.
The problem PowerShell command is Write-Host. If I change Write-Host $JulianDate to just $JulianDate, there is no error, and works just as if called from PowerShell.
I have many .ps1 files that use Write-Host.
Can PSHELL be made to work with Write-Host?
Joe
The problem PowerShell command is Write-Host. If I change Write-Host $JulianDate to just $JulianDate, there is no error, and works just as if called from PowerShell.
I have many .ps1 files that use Write-Host.
Can PSHELL be made to work with Write-Host?
Joe
Code:
TCC 21.01.49 x64 Windows 7 [Version 6.1.7601]
Copyright 2017 JP Software Inc. All Rights Reserved
Your evaluation period expires in 29 days.
You can buy Take Command, TCC, and CMDebug at https://jpsoft.com
[c:\utils]pshell julian.ps1
PSHELL: System.Management.Automation.CmdletInvocationException : Cannot invoke this function because the current host
does not implement it.
[c:\utils]powershell -file julian.ps1
7256
[c:\utils]type julian.ps1
#Calculate today's julian date
$Year = get-date -format yy
$JulianYear = $Year.Substring(1)
$DayOfYear = (Get-Date).DayofYear
$JulianDate = $JulianYear + "{0:D3}" -f $DayOfYear
Write-Host $JulianDate