1 vote
Import-Module TaskScheduler failed with "Unable to find type [__ComObject]"

Description

 
I'm writing a script to interact with the windows scheduler and want to add "Import-Module .\TaskScheduler" pointing at a local copy of the TaskScheduler module.
However, I get the error:

Unable to find type [__ComObject]: make sure that the assembly containing this type is loaded.
At F:\Slps\main\dev\Slps.Scheduled\TaskScheduler\Add-TaskAction.ps1:28 char:18

This error does NOT happen if I "Import-Module PowershellPack", but I don't want to import the whole module.

After some investigation, I found I needed to add

[Reflection.Assembly]::LoadWithPartialName("TaskSchdPS")

as the first line to TaskScheduler.psm1 and all was well.

File Attachments


No files are attached


Comments

most recent at top (show oldest at top)


Updating...
Page view tracker