Using .NET Types Directly

by Feb 23, 2016

Cmdlets contain pure .NET code, so thanks to cmdlets, you do not need to directly touch .NET code. You can, however. Here are a number of sample calls that illustrate how .NET methods can be accessed:

#requires -Version 2
[System.Convert]::ToString(687687687, 2)



[System.IO.Path]::ChangeExtension('c:\test.txt', 'bak')



# dangerous, save your work first

Add-Type -AssemblyName PresentationFramework
$dialog = New-Object Microsoft.Win32.OpenFileDialog

Twitter This Tip! ReTweet this Tip!