forked from KurtDeGreeff/PlayPowershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreating_NET_Objects.ps1
More file actions
30 lines (17 loc) · 832 Bytes
/
Creating_NET_Objects.ps1
File metadata and controls
30 lines (17 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# To create an object whose parent assembly is already loaded:
$object = new-object System.Int32
$object = new-object System.DateTime
$object = new-object System.Net.WebClient
$object = new-object System.Net.Mail.SmtpClient
# But if the assembly containing the class hasn't been loaded, you'll have to load it first:
[System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework")
$object = new-object Microsoft.Win32.OpenFileDialog
$object.ShowDialog()
$object.FileName
# Some .NET object constructor methods require one or more arguments:
$s = new-object -type System.String -argumentlist "Hello"
# To get hints about the possible constructor arguments for a type of object:
[System.String].GetConstructors() |
foreach-object { $_.getparameters() } |
select-object name,member |
format-table -autosize