titlerequired / public

Scripts
GNU General Public License v3.0
29 stars 14 forks source link

How to adjust settings #19

Open Tien7689 opened 3 years ago

Tien7689 commented 3 years ago

I don’t know much about powershell settings Can you give me an example

`#> param(

$smtpServer Enter Your SMTP Server Hostname or IP Address

[Parameter(Mandatory=$True,Position=0)]
[ValidateNotNull()]
[string]$smtpServer,
# Notify Users if Expiry Less than X Days
[Parameter(Mandatory=$True,Position=1)]
[ValidateNotNull()]
[int]$expireInDays,
# From Address, eg "IT Support <support@domain.com>"
[Parameter(Mandatory=$True,Position=2)]
[ValidateNotNull()]
[string]$from,
[Parameter(Position=3)]
[switch]$logging,
# Log File Path
[Parameter(Position=4)]
[string]$logPath,
# Testing Enabled
[Parameter(Position=5)]
[switch]$testing,
# Test Recipient, eg recipient@domain.com
[Parameter(Position=6)]
[string]$testRecipient,
# 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

)`

I get an error message after I execute it image

Tien7689 commented 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"

Notify Users if Expiry Less than X Days

[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

無法將值 "System.String" 轉換為型別 "System.Management.Automation.SwitchParameter"。布林參數只接受布林值或數值,例如 $T rue、$False、1 或 0。 位於 C:\Users\Administrator\Desktop\shell\PasswordChangeNotification29.ps1:22 字元:5

titlerequired commented 3 years ago

You should watch this. https://www.youtube.com/watch?v=eLo5sylezA0&t=118s

Tien7689 commented 3 years ago

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