Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using -WhatIf or omitting -Confirm:$false/-Force fails on functions #15

Open
kbakk opened this issue Aug 8, 2017 · 1 comment
Open

Comments

@kbakk
Copy link
Contributor

kbakk commented Aug 8, 2017

I noticied this when running the commands Set-isiClusterOwner -location "Bergen"

Expected: The command should prompt if I want to continue, stating the cluster I'm performing the action on.

Actual:

Set-isiClusterOwner : The variable '$parameter1' cannot be retrieved because it has not been set.
At line:1 char:1
+ Set-isiClusterOwner -location "Bergen"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (parameter1:String) [Set-isiClusterOwner], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined,Set-isiClusterOwner

Going through IsilonPlatformSet.ps1 and IsilonPlatformRemove.ps1, I notice several cases where $parameter1 is not set.

This may be related to #12 .

@kbakk
Copy link
Contributor Author

kbakk commented Aug 8, 2017

I tried to work around this by adding the line if (-not (Test-Path variable:parameter1) ){$parameter1 = "Inhereted from session"}.

This allows me to run with -WhatIf, but I then see a new error:

Set-isiClusterOwner : The variable '$ISIObject' cannot be retrieved because it has not been set.
At line:1 char:1
+ Set-isiClusterOwner -location "Bergen" -WhatIf
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (ISIObject:String) [Set-isiClusterOwner], RuntimeException
    + FullyQualifiedErrorId : VariableIsUndefined,Set-isiClusterOwner

This made me investigate this error (VariableIsUndefined), and I found that it's an error thrown when a variable is undefined and Set-StrictMode -Version Latest is set. This is the case here (it's set in IsilonPlatforSet.ps1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant