PSPushTeams
PSPushTeams copied to clipboard
.AddDays($) fails if $ is a var and only if scheduled via task scheduler
Found when setting up scheduled tasks and adding start-transcript at beginning of script to see why it would 'pass' but never send.
Even if we set $maxPasswordAge = 90 it will still change it to 90.00:00:00. if it was set to 90.00 it would pass.
Var can be Int32 and still fail
Cannot convert argument "value", with value: "90.00:00:00", for "AddDays" to type "System.Double": "Cannot convert the "90.00:00:00" value of type "System.TimeSpan" to type "System.Double"." At C:\Automation\PSPush_expiryUsers2.ps1:42 char:3
-
$expireson = $passwordsetdate.AddDays($maxPasswordAge) -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [], MethodException
- FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
Current work around is to enter your max password age manually. $passwordsetdate.AddDays(90)