Skip to main content

Using .NET Types Directly

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!

Posted Feb 23 2016, 06:00 AM by ps1


I am the one