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
)
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.