SQLReporting.psm1

by fan4nyr2003 at 2013-03-21 13:53:22

Hi… I am a newbie and trying your reporting ebook “Making Historical and Trend Reports in PowerShell” and following every step I have run into an issue. When importing the module I get the below error. As you can see the SQLReporting.psm1 file is in the right location as specified in the ebook, but the error is related to something within this file. Is there anyway you can help?

PS C:\Windows\system32> Import-Module SQLReporting
You must provide a value expression on the right-hand side of the ‘-’ operator.
At C:\Users\mrichter\Documents\WindowsPowerShell\Modules\SQLReporting\SQLReporting.psm1:145 char:28
+ if ($property - <<<< in ‘@(‘name’,‘computername’,‘collected’)’) {
+ CategoryInfo : ParserError: (:slight_smile: [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression

Import-Module : The specified module ‘SQLReporting’ was not loaded because no valid module file was found in any module
directory.
At line:1 char:14
+ Import-Module <<<< SQLReporting
+ CategoryInfo : ResourceUnavailable: (SQLReporting:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand


Thanks
by poshoholic at 2013-03-21 14:07:31
Make sure you don’t have any spaces between the “-” and “in” for the “-in” operator.
by poshoholic at 2013-03-21 14:08:58
Also, further along that line, it looks like you put quotes around the array enclosure. The line should look like this:
if ($property -in @(‘name’,‘computername’,‘collected’)) {
by fan4nyr2003 at 2013-03-21 14:17:40
I apologize for posting my attempt on fixing this code (and not sure if a fix is required) but this is what the code looks like when downloaded from this site

if ($property -in @(‘name’,‘computername’,‘collected’)) {
$indexes += $property
}


and here is the error again

PS C:\Windows\system32> Import-Module SQLReporting
You must provide a value expression on the right-hand side of the ‘-’ operator.
At C:\Users\mrichter\Documents\WindowsPowerShell\Modules\SQLReporting\SQLReporting.psm1:137 char:28
+ if ($property - <<<< in @(‘name’,‘computername’,‘collected’)) {
+ CategoryInfo : ParserError: (:slight_smile: [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression

Import-Module : The specified module ‘SQLReporting’ was not loaded because no valid module file was found in any module
directory.
At line:1 char:14
+ Import-Module <<<< SQLReporting
+ CategoryInfo : ResourceUnavailable: (SQLReporting:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
by poshoholic at 2013-03-21 14:22:45
Ok, I see the real problem now. You’re using PowerShell 2.0. That module requires PowerShell 3.0.