I have 2 scripts. One named 2022.ps1 that simply has this:
##Year Driver##
$curDir = Get-Location
& ".\January\Jan2022.ps1"
This code should run the Jan2022.ps1 script which runs fine if I run that on it's own. But when being called from 2022 I get the following error:
Cannot convert null to type "System.DateTime".
At C:\Users\Dummy\Desktop\2022All\January\Jan2022.ps1:47 char:5
+ $regDateCheck = ([DateTime]$regDateCheck).ToString("MM-yyyy")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : nullToObjectInvalidCast
Why is this happening? I need to call scripts for the rest of the months as well.