Open Tien7689 opened 3 years ago
i adjust settings like this , it works
$smtpServer Enter Your SMTP Server Hostname or IP Address [Parameter(Mandatory=$True,Position=0)] [ValidateNotNull()] [string]$smtpServer = "mail.abc.com"
[Parameter(Mandatory=$True,Position=1)]
[ValidateNotNull()]
[int]$expireInDays = "7"
# From Address, eg "IT Support <support@domain.com>"
[Parameter(Mandatory=$True,Position=2)]
[ValidateNotNull()]
[string]$from = "IT_support <it_support@abc.com>"
[Parameter(Position=3)]
[switch]$logging,
# Log File Path
[Parameter(Position=4)]
[string]$logPath = "d:\PS-pwd-expiry.csv"
# Testing Enabled
[Parameter(Position=5)]
[switch]$testing = "Enabled"
# Test Recipient, eg recipient@domain.com
[Parameter(Position=6)]
[string]$testRecipient = "it_support@abc.com"
# Output more detailed status to console
[Parameter(Position=7)]
[switch]$status,
# Log file recipient
[Parameter(Position=8)]
[string]$reportto,
# Notification Interval
[Parameter(Position=9)]
[array]$interval
``
But the error message still appears as fllow , can you tell me how to debug??
無法將值 "System.String" 轉換為型別 "System.Management.Automation.SwitchParameter"。布林參數只接受布林值或數值,例如 $T rue、$False、1 或 0。 位於 C:\Users\Administrator\Desktop\shell\PasswordChangeNotification29.ps1:16 字元:5
+ CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
+ FullyQualifiedErrorId : RuntimeException
無法將值 "System.String" 轉換為型別 "System.Management.Automation.SwitchParameter"。布林參數只接受布林值或數值,例如 $T rue、$False、1 或 0。 位於 C:\Users\Administrator\Desktop\shell\PasswordChangeNotification29.ps1:22 字元:5
+ CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
+ FullyQualifiedErrorId : RuntimeException
You should watch this. https://www.youtube.com/watch?v=eLo5sylezA0&t=118s
i got it!!!!!!
thanks help!!!!
in Powershell
c:\ .\1PasswordChangeNotification29.ps1 -smtpServer abc.com -expireInD ays 7 -from "It support it_support@abc.com" -logging -logPath d:\ -testing -testRecipient test@abc.com
I don’t know much about powershell settings Can you give me an example
`#> param(
$smtpServer Enter Your SMTP Server Hostname or IP Address
)`
I get an error message after I execute it