aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
236 stars 78 forks source link

ImportGuard.ps1 fails with Strict Mode #90

Closed juancrl closed 4 years ago

juancrl commented 4 years ago

When using Strict Mode,

The property 'Count' cannot be found on this object. Verify that the property exists.

At C:\Users\myuser\Documents\PowerShell\Modules\AWS.Tools.Common\4.0.1.1\ImportGuard.ps1 and also At C:\Users\myuser\Documents\PowerShell\Modules\AWSPowerShell\4.0.1.1\ImportGuard.ps1:6 char:13

The .Count property does not exist when a single object is returned in PowerShell. The default promotion to an array does not work in several scenarios, as in this one.

Solution, use the Array cast operator : if ($importingModule.Count -eq 1) { should be if (@($importingModule).Count -eq 1) {

Careful, there's another similar .Count reference in other line. Same problem found in AWSPowerShell module.

matteo-prosperi commented 4 years ago

Hello, thanks for opening this issue. We will try to address this as soon as possible and make the module compatible with Strict Mode.

matteo-prosperi commented 4 years ago

Hello, this was addressed as part of the latest release. I am closing this, please reopen in case you experience further issues. Thanks