我有几个工作代码点现在不再有效。这是一段代码:
if ($day -eq 01) {
echo "The Day of Days" }
else {
echo "Not Today" }
我得到以下结果:
At D:\PS_Scripts\Archive-Log.ps1:88 char:15
+ echo "The Day of Days" }
+ ~~~
Unexpected token 'The' in expression or statement.
我尝试使用 Write-host 并得到相同的结果:
At D:\PS_Scripts\Archive-Log.ps1:88 char:21
+ Write-Host "The Day of Days" }
+ ~~~
Unexpected token 'The' in expression or statement.
我也遇到了评论行的问题并得到以下信息:
At D:\PS_Scripts\Archive-Log.ps1:87 char:29
+ # {($_ -ieq "LOG") } {
+ ~~~~~~~~~
Unexpected token 'LOG") } {
# Write-LogRecord -M $Return.message }
# {($_ -ieq "NOLOG")} {
# Write-Host $Return.message }
# default {
# Write-Host '$msgE1'
# Write-EventLog -LogName Application -Source $global:USER_SOURCE `
# -EventID 4001 -EntryType Information -Message "$msgE1"
# Write-EventLog -LogName Application -Source $global:USER_SOURCE `
# -EventID 2001 -EntryType Error -Message $Return.message } }
我也有将哈希表返回给调用程序的问题,该程序有效且不再有效,如下所示:
Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Collections.Hashtable".
At D:\PS_Scripts\Archive-Log.ps1:82 char:9
+ $ReturnCD = Create-Directory -D $ArchiveDir
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
+ FullyQualifiedErrorId : RuntimeException