What is :: ?

Hi all,

This is my first post !
In the line [System.Windows.Forms.MessageBox]::Show(“Hello World!”) what does the :: mean/do ?
Also, why is there the need to use “System.Windows.Forms.MessageBox” and not a verb-noun syntax ? What is the difference ?

Many thanks all !

Hi Graham,

You are referring to a .NET class, which will often require you to specify it’s entire name space as well. The ‘::’ tells PowerShell that what follows is one of the attributes of the class, which typically can consists of one or more constructors, enumerations, methods, or properties.

Take a look at https://msdn.microsoft.com/en-us/library/system.windows.forms.messagebox(v=vs.110).aspx to get an idea what I’m referring to.

This is also the reason why there is no Verb-Noun format. You’re not referring to a PowerShell cmdlet, but directly to a .NET class.

If you want to get a list of currently registered cmdlets, you can use the Get-Command Cmdlet.

There’s some pretty good articles available about using .NET with PowerShell. Take a look at Scripting Guy who has written a few.

Hope this helps.

Many thanks