This project is read-only.

INE parameter

Topics: Archive - Deployment Scripts
Nov 23, 2014 at 10:52 PM
Hi,
  1. What is the signification of : If ($deploymentType -ine 'Uninstall')?
    ne mean not equal but ine?? I found no reference about "ine".
  2. I was looking to the script and found you are using a lot of if else if. Why not using a switch? Would not it be cleaner?
Thanks,
Developer
Nov 23, 2014 at 11:01 PM
Edited Nov 23, 2014 at 11:02 PM
The PowerShell comparison operators such as -ne are case-insensitive by default. But if you want to explicitly specify case-insensitivity, you can add an "i" in front of any of them. If you wanted to do a case-sensitive comparison, you can add a "c" in front of the operator such as "-cne" and that would force case sensitivity.

Switch or if/else doesn't really matter. I guess it's a matter of style/choice.
Nov 23, 2014 at 11:04 PM
Do you have a reference about the "i"?

You are right, if is a matter of choice/style.

Thanks,

François
Developer
Nov 23, 2014 at 11:12 PM
http://technet.microsoft.com/en-us/library/hh847759.aspx

Just search on the page for "case" and you should see the text about this.
Coordinator
Nov 23, 2014 at 11:24 PM
We could probably use switch statements more than we have but they are limited in that you can't perform comparisons with them and more complex workflow logic requires the use of if-else statements.
Developer
Nov 23, 2014 at 11:31 PM
Edited Nov 23, 2014 at 11:32 PM
I thought the same until last night when I was working on something :).

See the below for an example of how to do comparisons with switches:
Swtich ($_) {
    'a' {
        Do something
    }
    2 {
        Do something
    }
    { $_ -eq 34} {
        Do something
    }
    { 1,2,3 -contains $_ } {
        Do something
    }
}
Nov 24, 2014 at 2:39 AM
Hi,

I was thinking about the main job of a package: Install, Uninstall.. and repair (for MSI).

I believe using if elseif is trivial in those situation. Sound betterr to use Switch install, uninstall, repair and use if Inside each statement.

Thanks,

François