Link to home
Start Free TrialLog in
Avatar of norman eng
norman eng

asked on

Power Shell invalid syntax.

Hi Experts, I am very new to PowerShell scripting, came across an script that is for AD password expiry notification from TechNet, I tried to input the variables, but somehow there is some error that I don't really understand.

The first error is Missing ')' in function parameter list.
The second error is Unexpected token ')' in expression or statement.

Kindly refer to the attached file for the scripting error syntax, and the original file that I have download from TechNet.

The file that I have download is from this source.

https://gallery.technet.microsoft.com/scriptcenter/Password-Expiry-Email-177c3e27

Kindly advise.
scripting-issue.png
Avatar of oBdA
oBdA

These are not parameters you're supposed to edit, you're supposed to pass them in the command line when calling the script.
As in
.\PasswordChangeNotification.ps1 -smtpServer mail.abcdefg.com -expireInDays 10 -from abcdef@abcdefg.com ...

Open in new window

Or if you edit the script (which means these values will be taken as default when they're not passed in the command line, then keep the comma at the end of the line
    [Parameter(Mandatory=$True,Position=0)] 
    [ValidateNotNull()] 
    [string]$smtpServer = "mail.abcdefg.com", 
    # Notify Users if Expiry Less than X Days 
    [Parameter(Mandatory=$True,Position=1)] 
    [ValidateNotNull()] 
    [int]$expireInDays = 10,
...

Open in new window

Avatar of norman eng

ASKER

hi oBdA thank you for your input, it has indeed resolve the error, but after I have edited the script inputting the default value (Kindly refer to the attached scripting issue_v2) , and run the script, it will prompt me to input the value again, (kindly refer to the prompting.png).

kindly advise.

Thanks.
Scripting-issue_v2.PNG
Prompting.PNG
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi oBdA, got it, thanks alot.
thanks alot, it works.