troubleshooting Question

Powershell error for NTP time offset

Avatar of snyderkv
snyderkv asked on
Powershell
3 Comments1 Solution133 ViewsLast Modified:
EE,

I pasted a piece of code below but get an error seen here. It's part of an NTP time snippet that alerts when the offset exceeds a threshold but this is the piece that errors out. Please assist.

Thanks again

+     [OutputType()]
+     ~~~~~~~~~~~~~~
Unexpected attribute 'OutputType'.
+     Param (
+     ~~~~~
Unexpected token 'Param' in expression or statement.
+         [String]$Server = "domain.com",
+                           ~~~~~~~~~~~~~~~
The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedAttribute

This is the code.

$api=New-Object -comObject "MOM.ScriptAPI"
$PropertyBag = $api.CreatePropertyBag()

Set-StrictMode -Version 3

    [CmdletBinding()]
    [OutputType()]
    Param (
        [String]$Server = "Domain.com",
        [Int]$MaxOffset = 1000,     # (Milliseconds) Throw exception if network time offset is larger
        [Switch]$NoDns               # Do not attempt to lookup V3 secondary-server referenceIdentifier
    )
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros