This project is read-only.

Unable to get-help

Feb 10, 2014 at 2:58 PM

Just wanted to let you know that on Server 2012, I am unable to run:

get-help .\New-CMMaintenanceWindow.ps1 -full

It returns:
get-help : Get-Help could not find .\New-CMMaintenanceWindow.ps1 in a help file in this session. To download updated
help topics type: "Update-Help". To get help online, search for the help topic in the TechNet library at
At line:1 char:1
  • get-help .\New-CMMaintenanceWindow.ps1
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
    • FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand
Feb 10, 2014 at 3:32 PM

Are you using this from within the "SCCM"-powershell command shell?? If so there seems to be a bug.
I get the same error if I try the command from the powershell promt started from the SCCM console. If I start a normal Powershell promtp on the same server it works. Might be a bug with the SCCM powershell prompt and nothing I can fix. Just open the file with a text editor and you will also see the help text.

Feb 10, 2014 at 5:06 PM
Hi Matt,

I have tried on several servers, 2012, 2008 and Windows 8, in both 64-bit and 32-bit PowerShell and they all fail.

PS C:\Users\a-dpa42779\desktop> get-help .\New-CMMaintenanceWindow.ps1 -full
Get-Help : Cannot find Help for topic ".\New-CMMaintenanceWindow.ps1".
At line:1 char:9
  • get-help <<<< .\New-CMMaintenanceWindow.ps1 -full
    • CategoryInfo : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
    • FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand
Feb 10, 2014 at 6:17 PM
I think I found a bug as well. When I created the Maintenance Windows using the following:
.\New-CMMaintenanceWindow.ps1 -SiteCode S01 -MaintenanceWindowName "Windows Updates" -AddMaintenanceWindowNameMonth -CollectionID "S0100027" -PatchTuesday -adddays 3 -StartYear 2014 -startHour 22 -startMinute 0 -HourDuration 8 -MinuteDuration 0

The Windows for the year were all created. Awesome!

However when I verified the windows, March was 9pm-5AM and November was 11pm-7AM. Still 10 hour windows, but they were off by an hour either way.
This behavior is repeatable using the same command string as above, but changing the CollectionID and adddays.
Feb 11, 2014 at 7:50 AM
This is strange, I have tried the same in my lab and on a testcollection in our production. I cannot reproduce your issue I am afraid.
What locale are you using? What version of powershell are you using? What timezone do you use on your server? Do you run the script locally on the server?

It feels very strange that the time would be offset both -1 and +1 hour during the same command since the code should use the same method during all "months".

Could you try to add the -IsGMT switch and then adjust your starthour to GMT time manually just to see if the behaviour is diffrent?
Sep 11, 2014 at 9:05 PM
Edited Sep 11, 2014 at 9:06 PM
I can reproduce this behavior.

Location: US
PoSh Version: 2.0
Timezone: Central Daylight Time (UTC -6:00)
Script: Ran on Server

The offsets appear to coincide with Daylight Savings Time. I've set the maintenance windows with and without the -IsGMT switch and in both cases, it creates the +/- 1 hour variance for the months of March and November. I am only guessing at the cause because I don't have more time to trace it, but you might look at this line in the main section of the script:

[datetime]$MWstartTime = ($newdate).ToUniversalTime()
Oct 28, 2014 at 5:54 PM
First off, BIG THANK YOU, for writing this script. Why this functionality isn't included in R2 natively is beyond me.

I am also experiencing the same issue with daylight savings time.

I'm running version 1.1 of the script.

We are in the EST timezone and observe daylight savings time.

For the months that DST take effect (March and November) the start times for maintenance windows are being set +/- 1 hour.

Another issue I am experiencing and I have confirmed this all the way through 2015, is that any month where the 1st starts on a Wednesday, effectively pushing the 2nd Tuesday into the 3rd week of the month, the effective date of the months respective maintenance window is configured as if Patch Tuesday occurred the 1st Tuesday of the month.

Here are the parameters I am using with the script:

-patchTuesday -adddays 5 -startyear 2014 -StartHour 00 -StartMinute 0 -HourDuration 6 -MinuteDuration 0

Any thoughts?

Oct 30, 2014 at 4:32 PM
Edited Oct 30, 2014 at 4:45 PM

The issue about get-help not beeing able to work seems related to that ps1 files downloaded seems "untrusted", if you try and create a new empty ps1 file and then paste and copy the content from New-CMMaintenanceWindow it seems to work. Im not sure how to fix this since it seems like default PS behaivor (bug?). There is a commandlet called unblock-file but it did not help when i tried it.

I will try to see why the hours and dates go wrong, maybe I calculate them in the wrong order. Using the same settings as you atleast I was able to reproduce the time issue which is a good start :D For me when i use the following

-patchTuesday -adddays 5 -startyear 2015 -StartHour 00 -StartMinute 0 -HourDuration 6 -MinuteDuration 0

The MW for April 2015 (1:st is a wed) the MW is created for the 19:th wich is 5 days after the second tuesday?

Dec 19, 2014 at 1:34 PM
Edited Dec 19, 2014 at 1:35 PM
Hi all,

I have finally gotten the time to rewrite the code, hopefully it works better for everyone no matter what timezone you are in.
Please provide feedback if it works for you!

New-CMMaintenanceWindow v1.2